On Thu, Feb 04, 2010 at 11:58:10AM -0800, Karen Etheridge wrote:
> Doh let me rephrase (of course they are different - trigger acts like an
> 'after'  method modifier on the setter, whereas initializer acts like an
> 'around'). Is there anything one can do with an initializer that can't be
> done with a trigger?  If one wants to change the value of an attribute if a
> particular value was assigned, one could simply call $attr->set_raw_value,
> but that bypasses type coercion and some other nice things. Calling
> set_value would cause an infinite loop in the trigger.
> 
> The only other way through this that I see is to add a new meta-attribute
> method set_value_without_trigger, but that's gross!

doy set me straight:

12:34 < ether> so. after thinking through my post to the mailing list, I think
               there might be a use for initializers after all
12:35 < ether> there's no other good way of munging a value being assigned to
               an attribute, other than writing an explicit 'around' method
               modifier to the setter, and IMHO one should never have to depend
               on a setter's name
12:36 < ether> so what I'd do is simply change initializer so that it's always
               called on set, rather than just when $old_value is undef... if
               one passes $new_value and $old_value to the method, then one can
               still achieve the old behaviour if desired
12:37 <@doy> ether: accessor meta-trait
12:37 < ether> ah, to add on new behaviour in set_value? yes that would work
12:38 < ether> much better; thank you!

I'm satisfied now: there is no usecase for an initializer that couldn't
be achieved using either a trigger or by modifying the behaviour of the
attribute's setter.



-- 
Karen Etheridge, ka...@etheridge.ca       GCS C+++$ USL+++$ P+++$ w--- M++
http://etheridge.ca/                      PS++ PE-- b++ DI++++ e++ h(-)

Reply via email to