On Tuesday 10 November 2009 00:31:57 Dave Rolsky wrote:
> On Tue, 10 Nov 2009, Nathan Gass wrote:
> > They are mainly useful for overwriting. My current code for
> > MooseX::Attribute::Delegated at
> > http://github.com/xabbu42/MooseX-Attribute-Delegated
> > has to use a custom Method::Accessor and a custom Method::Constructor
> > with two mostly copy-pasted methods (see
> > http://github.com/xabbu42/MooseX-Attribute-
> > Delegated/blob/master/lib/MooseX/Attribute/Delegated.pm)
> 
> Not to get too off-topic, but what is the point of what you're doing?
> 
> If you want to extract a bunch of attributes from a hashref passed to the
> constructor as one of its arguments, there are lots of simpler ways to do
> this.
> 
> Notably, a parameterized role that added a method modifier on BUILD would
> probably be a _much_ simpler solution. You could also just use a lazy
> builder.

I mainly want an attribute which works with normal object introspection (-
>meta->get_all_attributes and company). Later it could eventual be interesting 
to add other Extensions which change the behavior of attributes like for 
example MX::TrackDirty::Attributes. Both of this only work if I have a real 
attribute meta-object.

What you describe is actually currently not implemented in 
MX::Delegated::Attribute, since this point is not very important to me.

> 
> > as I see it, Method::Constructor defines the behavior of a constructor
> > and should not presuppose the way a specific attribute gets stored in the
> > object. How an attribute gets stored should instead be decided by the
> > attribute meta- object. Same story for Method::Accessor. I'll try to find
> > an example on CPAN for this point.
> 
> The Constructor doesn't assume anything about how attributes are stored,
> it asks the meta-instance to handle this detail. This is all really
> confusing without adding yet another layer of indirection.

The Constructor assumes that every attribute gets stored in a single slot 
directly in the object.

> 
> > My changes streamline some inconsistencies in the current code too. The
> > current code uses sometimes $attr->name and sometimes $attr->slots to
> > decide on the slot name. Overwriting the slots method of Meta::Attribute
> > therefore currently gives you a buggy attribute, since some code
> > incorrectly still uses the name of the attribute as slot name. This bug
> > can of course be fixed without my changes. The point is that bugs like
> > this are easier avoided if all code concerning inline attribute storage
> > is concentrated in one place.
> 
> I'd like to see that bug fixed too.
> 
> However, attribute storage is already in one place, the meta instance.

Yeah, but the meta instance is the same for all attributes. So there is no way 
to change how a single attribute gets stored.

- xabbu42

> 
> 
> -dave
> 
> /*============================================================
> http://VegGuide.org               http://blog.urth.org
> Your guide to all that's veg      House Absolute(ly Pointless)
> ============================================================*/
> 

Reply via email to