Re: TT's support for methods and complex structures. Why not?

Sam Tregar <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
On Mon, 18 Jul 2005, Mark Stosberg wrote:

> > #1 I can get behind.  #2 makes me itch.  There's a high potential for
> > abuse here since methods can have side-effects which would break the
> > straight data-path from code to template to output.
> 
> I'm also more interested in number 1 than number 2. Do you mean "get
> behind" as in: "go forth and prepare a patch ye feature requester"

I guess I mean if there was a module on CPAN that did this I might use
it.  I'm not presently inclined to include it in the core module, if
only because it's obviously something that would be easy to do in a
sub-class.

> In between the coder the designer is some kind of understanding about
> what valid token names are, usually provided by the programmer.
> 
> I think most often this communication is implicit because the programmer
> puts the tokens in the document in the first place. In this case,
> exactly how the tokens came to be isn't interest to the designer.

Right on.

> Wouldn't the method call support be sort of like coderef support that is
> already there?

Yes, although I'd wager that the percentage of anonymous subs that
have side-effects is much lower than the percentage of methods that
have side-effects.  I realize that either one could but methods just
seem more likely to encourage this abuse.

Although, if you want to get to the heart of the matter, code-ref
variables were not my idea.  I added them in response to a majority of
the users declaring their interest.  Sometimes I do that...

> It seems like it might even be implemented like that: as as callback
> which gets the method name passed in as a parameter.

Yes, I think that would be the easiest way.  HTML::Template::Expr
exploits code-ref variables to offer function calls, so why not
methods too?

-sam


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.