Sex, 2008-09-19 às 10:25 -0700, Jon Lang escreveu:
> Daniel Ruoso wrote:
> > In SMOP, it is handled based on the package of the Class, the private
> > storage inside the object is something like
> >   $obj.^!private_storage<A::><$!bar>
> > and
> >   $ojb.^!private_storage<B::><$!bar>
> Note that this ought only be true of class inheritance; with role
> composition, there should only be one $!bar in the class, no matter
> how many roles define it.

er... what does that mean exactly?

   role B {
       has $!a;
   }

   role C {
       has $!a;
   }

   class A does B, C {
       method foo() {
          say $!a;
       }
   }

I think in this case $!B::a and $!C::a won't ever be visible, while the
reference to $!a in class A will be a compile time error.

OTOH...

   role B {
       has $.a;
   }

   role C {
       has $.a;
   }

   class A does B, C {
       method foo() {
          say $.a;
       }
       method bar() {
          say $!a;
       }
   }

In that case, both B and C declare a *method* "a" which happens to be
visible in class A (and probably a composition error), but $!a in method
bar is still a compile time error, because there's no $!a declared in
class A.

Or does that mean that

    class A does B, C {...}

actually makes the declarations in B and C as if it were declared in the
class A?

daniel

Reply via email to