develooper Front page | perl.perl6.language | Postings from March 2005

Re: some misc Perl 6 questions

Thread Previous
Brent 'Dax' Royal-Gordon
March 9, 2005 02:53
Re: some misc Perl 6 questions
Message ID:
Darren Duncan <> wrote:
> A question: Would "has PkgNameArray @.tmpl_set_nms;" do what I
> expect, where the array as a whole is the sub-type, or would it make
> an array where each element is the sub-type?

I think this declares an array of PkgNameArrays, but "has
@.tmpl_set_nms is PkgNameArray;" will do what you want.

> New question: Is there a way to say that two classes have a
> privileged relationship, sort of like a marriage, such that each can
> see and/or change otherwise private attributes in objects of the
> other class, and yet the attribute list of each class is completely
> different from the other?  Neither of the two objects is a subclass
> of the other, nor fulfills a role defined by the other.


Attributes are never visible outside a class definition, so a multi
method can only directly access the attributes of a class it's defined
within. However, it may call the private attribute accessors from a
different class if that other class has indicated that it trusts the
class the multi method is defined in:

    class MyClass {
        trusts Yourclass;

(end quote)

So for the relationship to work both ways, each class would have to
mark the other as trusted.

Brent 'Dax' Royal-Gordon <>
Perl and Parrot hacker

"I used to have a life, but I liked mail-reading so much better."

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About