On Thu, Nov 05, 2009 at 10:20:27PM +0100, Nathan Gass wrote:
> > > > I had to copy-paste two methods from
> > > > Moose::Meta::Method::Constructor with
> > > > very little changes. Any interest in changing Moose to avoid this?
> > > > Any ideas
> > > > how to do this properly?
> > >
> > > Would need to know more of what it is you actually did to know if we
> > > could do something in the Moose guts. And of course topic branches are
> > > *always* welcome :)
> > 
> > I had to overwrite _generate_slot_assignment and _generate_triggers, which
> >  are the only methods of of Meta::Method::Constructor which use the
> >  instance meta object to access slots. My versions are nearly identical.
> >  Imho
> > Method::Constructor should not assume an exact way how the Attribute uses
> > Meta::Instance to store itself in the object, but rather let the Attribute
> > decide.
> > 
> > I went ahead and tried to make the needed changes myself. The resulting
> >  diff is at
> > 
> http://github.com/xabbu42/moose/commit/a0cfca605c06d3e5c3750b6dc774e9b806bc5dd7
> > 
> > I get some failing tests because the M::Meta::Method::* in Moose apparently
> > need to work with Class::MOP::Attribute too. So for this approach to work,
> >  the diff for M::Meta::Attribute actually belongs into
> >  Class::MOP::Attribute.
> >
> So what about this change? Any chance to get it in Class::MOP/Moose if I 
> finish 
> and properly test it? Wrong approach?...

This looks reasonable to me, just needs tests/docs/Changes

> > 
> > By the way, why is sometimes $attr->slots and sometimes $attr->name used?
> I need to know if there is a difference here which should be supported.

Because in the default attribute implementation, each attribute has just
one slot, which has a name that's the same as the attribute, so it's
equivalent in this case. However, if an attribute were to decide to use
multiple slots, these would break, since all of the inline_*_value
methods on the instance assume a single slot is coming in, so these
should all probably be using ($attr->slots)[0] or something similar
(really, anyone who's messing around with the slots should be overriding
all of these methods anyway, but that seems to be the least likely to
break things).

-doy

Reply via email to