On Sunday, October 6, 2002, at 12:57  AM, Noah White wrote:

>>
>>> Note that an alternate definition of "private" is often used, as 
>>> follows:
>>>
>>>     A "private" attribute is an attribute whose scope is restricted 
>>> such that
>>>     it may be accessed only within the class in which it has been 
>>> declared,
>>>     OR WITHIN ANY CLASS THAT INHERITS FROM THAT CLASS.
>>
>> I'll agree with that.
>>
>
> ACK!  After re-reading this I about puked. No, that notion of private 
> would not be something I'd agree with :-) That's more like protected.

As I think I've mentioned once before, and will again as Eiffel's been 
mentioned recently...

Is there any chance Perl6 could simply avoid the can of worms that is 
public/private/protected and have a single accessibility property?  It 
would seem to clean the debate up handily, and provides even greater 
flexibility for programmers.  Along the lines of:

class Foo {
        attr $.bar is accessible(Bar, Baz);
        # Makes $.bar attribute accessible only to the Bar and Baz classes.
        attr $.baz is accessible(Foo);
        # Protected
        attr $.hello is accessible(None);
        # explicitly Private
        attr $.world is accessible(Any);
        # Public
}

Of course, if Perl6 went down this road, Ruby-ish read, write, or 
read/write attributes would also be nice.  I might want to let another 
class read an attribute, but not write to it, while I might for some 
reason want another class to be able to write to an attribute, but not 
read it.  But maybe I'm just weird that way.  :-)

Reply via email to