List Info

Thread: 5.10 showstopper? fields and private keys




5.10 showstopper? fields and private keys
user name
2007-09-04 19:43:29
I posted up a bug about problems with fields and private
keys.
h
ttp://rt.perl.org/rt3/Ticket/Display.html?id=44969

In short:  An inherited object can't use the private fields
of a parent *even
inside the parent's private method*.

I think this is a 5.10 showstopper, though not a critical
one, as it's
demonstratively broken with respect to 5.8.  The only CPAN
module I've seen
broken is IMDB::Film.


-- 
There will be snacks.


Re: 5.10 showstopper? fields and private keys
user name
2007-09-04 20:27:30
On Sep 04 2007, Michael G Schwern wrote:
> I posted up a bug about problems with fields and
private keys.
> h
ttp://rt.perl.org/rt3/Ticket/Display.html?id=44969
> 
> In short:  An inherited object can't use the private
fields of a parent *even
> inside the parent's private method*.

The problem is that restricted hashes fix the allowable keys
at the time
they are locked, which in this case is fields::new().  I
don't see how
this can be fixed to work the way it did before.

We could change things so that private fields are in the set
of allowed
keys in the derived object.  This would mean they would no
longer be
strictly private but accesses with constant keys would still
get caught.
So

    $base->;      # ok
    $derived->;   # rightly croaks at
compile-time
    $derived->{$private};   # wrongly accesses private
field

I think this is an improved state of brokenness.  What do
you think?

-- 
Rick Delaney
rickbort.ca

Re: 5.10 showstopper? fields and private keys
user name
2007-09-04 20:43:59
Rick Delaney wrote:
> On Sep 04 2007, Michael G Schwern wrote:
>> I posted up a bug about problems with fields and
private keys.
>> h
ttp://rt.perl.org/rt3/Ticket/Display.html?id=44969
>>
>> In short:  An inherited object can't use the
private fields of a parent *even
>> inside the parent's private method*.
> 
> The problem is that restricted hashes fix the allowable
keys at the time
> they are locked, which in this case is fields::new(). 
I don't see how
> this can be fixed to work the way it did before.
> 
> We could change things so that private fields are in
the set of allowed
> keys in the derived object.  This would mean they would
no longer be
> strictly private but accesses with constant keys would
still get caught.
> So
> 
>     $base->;      # ok
>     $derived->;   # rightly croaks at
compile-time
>     $derived->{$private};   # wrongly accesses
private field
> 
> I think this is an improved state of brokenness.  What
do you think?

+1

"It works, but encapsulation can be violated" is
better than "it's broken" and
eliminates this as a showstopper.


-- 
Hating the web since 1994.

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )