On Tue, Nov 16, 2010 at 11:32:55AM -0600, Evan Carroll wrote:
> Because a role doesn't have a BUILD people often write `around 'BUILD'
> => sub {}`. If this is to continue, should BUILD be special cased such
> that a role wrapping it can still fire code if it isn't present in the
> composing class? Should the role install BUILD if it isn't present,
> like an `override_or_after 'BUILD' => sub {}`?Yes, there should be a better way to do this, but override_or_after is absolutely the wrong solution. BUILD (and DEMOLISH) isn't a normal method, so Moose shouldn't handle it like a normal method (including rules for composition and such). Getting this right just isn't very high on peoples' priority lists at the moment, since a workaround does exist, even if it's not that great. > I've just got an Attribute Trait which I want to set from within in a > role, I do that currently by wrapping BUILD. Sounds like you could probably just give the attribute a lazy default, although I don't really know anything about the rest of the application. -doy
