[stringtemplate-interest] ST4: Early evaluation of default arguments

Sam Harwell sharwell at pixelminegames.com
Sun May 1 10:59:43 PDT 2011


IMO, properties of objects evaluated during the ST rendering process should
never have side effects. Ever. It just gets possible to cover all possible
semantics if that's allowed.

 

Given this, there is no difference between {.} and ({.}). Within a given
scope, a template always evaluates to the same result, rather it's one time
or twenty. :)

 

If you are passing  template as a parameter to another template, then it
could be evaluated in different scopes (potentially with different results).
If you want it to always have the same result, you can pass it in
(parenthesis) to evaluate it to a string before passing it as a parameter.

 

Sam

 

From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Udo
Borkowski
Sent: Saturday, April 30, 2011 5:39 AM
To: stringtemplate-interest Template
Subject: [stringtemplate-interest] ST4: Early evaluation of default
arguments

 

Currently the only way to enforce early evaluation of template default
arguments is through the syntax:

 

     p = {<(...)>}

 

I.e. one can only early evaluate anonymous template that contain just an
expression tag.

 

 

It would be nice to also support early evaluation on any kind of anonymous
template.

 

E.g. in
http://www.antlr.org/pipermail/stringtemplate-interest/2009-August/002097.ht
ml Ter gave the following example:

if(cond, block, label={end<(uniq)>}) ::= << ... >>

 

However this will not give the expected result in ST4 (early evaluation of
"end<(uniq)>").

 

Maybe we could extend the syntax for default arguments to also support

      p = ({ ... })

 

i.e. putting "( . )" around the template forces early evaluation?

 

 

What do others think?

 

Udo

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110501/dec7601c/attachment.html 


More information about the stringtemplate-interest mailing list