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

Jesse Vincent jesse at bestpractical.com
Thu Oct 8 15:47:25 EDT 2009




On Wed, Oct 07, 2009 at 11:24:25AM -0700, David E. Wheeler wrote:
> On Oct 6, 2009, at 10:05 PM, David E. Wheeler wrote:
> 
> >> In imported templates, the invocant is an object blessed into the
> >> class into which the templates were imported.
> >>
> >> In aliased templates, the invocant is an object blessed into the  
> >> class
> >> from which the templates were aliased.
> >
> > Turns out that in neither case is an object passed. It looks like an
> > object is *never* passed. It's a class name. This, to me, makes the
> > distinction even less important.
> 
> It turns out that I was wrong to start with. The truth is that the  
> invocant is always the class from which the template was imported/ 
> aliased. The only subtlety is when mixing in or aliasing a subclass of  
> templates:
> 
> * When importing a subclass of templates, the invocant is always the  
> class in which each template was defined.
> 
> * When aliasing a subclass of templates, the invocant is always the  
> subclass, regardless of whether a particular template was defined in  
> the subclass or a parent.
> 
> This is a pretty minor difference, but I've updated the tests in the  
> mixmaster branch to confirm this (the tests were ambiguous before). Is  
> there any reason for this inconsistency, does any code rely on it, or  
> was it just an oversight of the implementation?

It's a small, but not minor difference, as it changed how things work in
use cases involving inheritance. I remember a design session with clkao
where we hashed out the need for both and wrote the skeleton of the
tests to demonstrate it.  What I don't remember is the actual use cases.
I'd really like to not break the old API, but I'd be happy to ship a
release with import_into Carp::cluck'ing with a message asking the user
to report the use case back to jifty-devel so we can doc how it was used
and find a newer, cleaner way to do what it did.

Does that seem like a reasonable way forward?

Best,
Jesse


More information about the jifty-devel mailing list