There are two branches for this, one for CMOP and one for Moose.
The CMOP branch is called topic/mi-methods-attributes. The "mi" refers to
multiple inheritance. What I've done is pull out "having methods" and
"having attributes" into two base clasess, CMOP::HasMethods and
::HasAttributes.
I know we talked about some sort of role-like system for this, but MI
works just as well for this particular usage, and getting role-like things
working in CMOP was proving _very_ difficult because of bootstrapping
issues.
The ::HasMethods class is a parent for ::Package. Since Moose::Meta::Role
already inherits from ::Package, this just works.
The ::HasAttributes class is a parent for ::Class.
In the Moose branch topic/roles-have-real-attributes I've made
Moose::Meta::Role also inherit from CMOP::HasAttributes.
When an attribute is added to a role, it gets an additional trait added to
it, Moose::Meta::Attribute::Trait::InRole. An attribute in a role does not
generate any methods (yet?).
This ::InRole trait also wraps the clone method to _remove_ itself as a
trait when the attribute is cloned. In other words, cloning an attribute
with the ::InRole trait returns a new attribute without that trait.
As you might guess, when a role is applied to a _class_, the role's
attributes are cloned and added to the class. The class ultimately ends up
with a copy of the attribute minus the ::InRole trait.
All the tests pass, and I really had to change very little there. I had to
change a bunch of the self-introspection related tests in CMOP, of course.
Other than that, most test changes were simply to account for the fact
that roles now have real attributes, so introspecting these attributes is
done differently.
This _will_ break backwards compat for anything that did introspection on
role attributes. I haven't looked for breakage yet.
For now, I'd appreciate a review of the design and concepts. If it's
acceptable, I'll add docs, fix breakage it causes in MX modules, and so
on.
-dave
/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/