[jifty-devel] Difference Between alias and import_templates in Template::Declare
Shawn M Moore
sartak at bestpractical.com
Wed Oct 14 14:38:15 EDT 2009
On Wed, Oct 14, 2009 at 11:15:54AM -0700, David E. Wheeler wrote:
> 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.
Sorry, I mean the ancient docs Jesse wrote, not what you are
writing. To be fair to Jesse though, we're spending a lot more time on
fine details, and have the benefit of a lot of experience with using TD.
> > Yes, agreed. I'm saying that we could have another separate feature
> > that
> > covers mixin/import.
>
> Hrm.
>
> > 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?
Sure, I just mean the programmer doesn't have to type the template names
mutiple times. I'm not sure that selecting which templates to delegate
to would be a useful feature. If it turns out we ever need it, we can add
it. It'll be easier than it would have been thanks to your refactoring. :)
> > 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.
Hmm. I'd like to avoid the underscore if we can. Maybe just "delegate"
or even "alias".
delegate Some::Class in This::Class under '/foo' setting { foo => 'bar' };
delegate Some::Class under '/foo';
shrug!
> Comments?
>
> Best,
>
> David
Shawn
More information about the jifty-devel
mailing list