Darren Duncan darren-at-darrenduncan.net |Perl 6| wrote:
I think that's not right. A private attribute defined in a role becomes
a private attribute of the composed class, so may be referred to from
other roles or the main class definition. In contrast, a "my" variable
inside the role is private to that role's block. Though it is put into
the object's attribute list (the scope is per-instance), it has no name
outside of the block.
A method is defined within a role or class, as is an attribute. A
private attribute can generally be referenced only by a method
declared in the same role or class as said attribute.
A method can reference its own role's/class's private attributes for
any objects of that role/class, regardless of whether said object is
the current method call's invocant or not.
OK, taking "class" only, not "role".
OK, trust is not implicit on derived classes. Is that because there is
no rule that says it is, or is there a mention of that somewhere in the
If a role or class is composed into another class or is subclassed, the
(for example) subclass can not reference the private attributes of its
As an exception to the above, if a particular class says that it
"trusts" a particular other class (using "trusts Otherclass;" as a
trait), then the trusted class can also reference the privates of the