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

David E. Wheeler david at kineticode.com
Wed Oct 14 14:15:54 EDT 2009

On Oct 14, 2009, at 11:05 AM, Shawn M Moore wrote:

> The old TD docs.. let's just say it's probably okay if we burn  
> them. :)

Heh. That's rather where I started with this. Jesse offered me the  
commit bit when I offered to submit doc patches.

> Yes, agreed. I'm saying that we could have another separate feature  
> that
> covers mixin/import.


> The identification doesn't have to be done explicitly by the  
> programmer.
> For example, in Moose, we have:
> has datetime => (
>    is      => 'ro',
>    isa     => 'DateTime',
>    handles => qr/.*/,
> );
> In TD, we similarly select all templates.

Well, no. With your example, you have to be explicit. With the current  
implementation it's implicit. You can't name which templates to  
delegate to. Not to say that that isn't a good idea, though…

> I'd rather not conflate the two.
> Say we have a class C that mixes in a mixin M and has an attribute  
> D. C
> delegates some methods to D. The methods provided by mixin M will  
> get C
> as the invocant. The methods that are delegated to D will get D as the
> invocant. There's a context switch involved with delegation that isn't
> present with mixins.

Agreed. There isn't currently a pure mixin model in T::D.

> The distinction is important. I'd really prefer to avoid clashing with
> established models. If we get it right we can just say "oh if you use
> this it's like a mixin, but if you use that it's like delegation."  
> If we
> get it wrong then users and experts alike will bang their heads  
> against
> it.

Fair enough.

> Both forms of composition are useful and good. I think we can have
> both in TD.

Okay. Then the question then becomes, what should we call the current  
delegation method?

   delegate_to Some::Class in This::Class under '/foo' setting { foo  
=> 'bar' };

I'd like a shorter expression than "delegate_to" (one reason I really  
liked `mix`), but maybe I'm just being obtuse.




More information about the jifty-devel mailing list