* Stevan Little <[EMAIL PROTECTED]> [2008-05-20T09:47:17]
> On May 19, 2008, at 8:30 PM, Bernardo Rechea wrote:
>> Grr, It would be quite a learning curve before I would able to understand
>> Moose well enough to even try... Do you think at least that having class
>> attributes declared in roles is reasonable?
>
> No, I don't think it is reasonable.
>
> Class attributes are really attributes of the metaclass instance (Dave 
> implements them slightly differently then that, but the effect is the 
> same). When a role is composed into a class, Moose will merge all the 
> attributes and methods defined in the role into the class. It does not 
> however merge all the attributes and methods from the metarole into the 
> metaclass.

This sounds, to me, like an argument from implementation, instead of from first
principles.

Is this statement true, outside the realm of how things are implemented:

  A role, when applied to a class, affects the behavior of instances, and only
  of instances?

I don't think it is, because it may add class methods.

Now, I know that this may be a bit of a lame argument, since Perl is so lousy
about distinguishing class and instance methods, so I will not insert a
dramatic sting and an "AHA!" here.  I just think that it's one bit of evidence
that roles affect class behavior as well as instance behavior.

If that's the case, class attributes should be able to be provided by a role.

If they can't be, then I could imagine myself very soon wanting to start using
a lot more factory objects, which would be annoying.

-- 
rjbs

Reply via email to