[jifty-devel] Difference Between alias and import_templates in Template::Declare

David E. Wheeler david at kineticode.com
Tue Oct 13 20:04:14 EDT 2009


On Oct 13, 2009, at 2:06 PM, Shawn M Moore wrote:

> Perhaps mixin is the wrong metaphor for alias. I think delegation is a
> better metaphor, since we really need the original class passed to the
> aliased templates. See also
> http://search.cpan.org/~drolsky/Moose-0.92/lib/Moose/Manual/Delegation.pod
> for a definition of delegation and why it's good.

Yes, delegation definitely better describes what it's doing, vis-a-vis  
dispatch. I was using the mixin metaphor (and the `mix` method) based  
on what I'd found in the docs so far.

> There's a place for the mixin metaphor, maybe that can be "import", or
> something new.

Well, `import` does something else in Perl. And it's not really an  
import, either (which would be more like a mixin).

Honestly, though, I think `mix` is still the best work to use for the  
feature because I can't think of a good way to make it happen with a  
delegation metaphor. Delegation usually identifies all of the methods  
to dispatch to when you specify it, as in:

   use Class::Delegator
       send => [qw(play pause rewind fast_forward shuffle)],
         to => 'ipod';

Which is not exactly how the TD feature works. What we're doing is  
mixing templates from one class into another class. The fact that the  
first argument is the mixed-in class rather than the target class is  
something that's easy to document and understandable.

So if it's okay with you and everyone else, I think I'd like to stick  
with `mix`. Unless you all prefer the original `alias` method. I'd be  
fine with that. Then it'd just be `import_templates` that'd be  
deprecated.

Best,

David








More information about the jifty-devel mailing list