Thom Boyer thom-at-boyers.org |Perl 6| wrote:
I believe Mr. Stroustrup's deprecation of 'protected' access applies
only to data data members, not function members:
Fortunately, you don't have to use protected data in C++; 'private'
is the default in classes and is usually the better choice. Note
that none of these objections are significant for protected member
*functions*. I still consider 'protected' a fine way of specifying
operations for use in derived classes.
-- Bjarne Stroustrup
_The_Design_and_Evolution_of_C++_
Section 13.9 [Protected Members]
So I understand Perl 6 will have no protected access for data members
(though trusted access can be used to provide a similar back door).
But does Perl 6 have protected access for methods?
=thom
I like the idea of using an interface (Role) to specify which methods
are allowed to be accessed, for which purposes. Add to that a way to
write type comprehensions; i.e. "All types T such that..." and you can
say "This abstract interface, beyond the default public interface, is
available to types which have this type as a base class."
A less general means would be to allow trust to be transitive when
granted as such.
Perhaps:
class C
does R1
does R2
is Base
{
does R3 :trusts(D :transitive);
does R4 :trusts(D|E);
is Base2 :private; # allows virtual overrides but no "isa"
static type
does R5 :trusts($?CLASS, :transitive); # like C++ "protected"
method ...
}
I think that syntax would work under the current situation, at least
when used inside the class block.
--John