[stringtemplate-interest] Expressions in $if(...)$ statements.

Terence Parr parrt at cs.usfca.edu
Mon May 18 10:17:01 PDT 2009


On May 15, 2009, at 4:39 PM, Magdalin, Vlad wrote:

> Thanks for the quick answers!
>
> I'm glad to hear that some sort of simple Boolean operators might make
> it into a subsequent release.
>
> About the other point (arithmetic comparisons, etc), you are totally
> right about the slippery slope, and it seems better to keep ST away  
> from
> going down that path.
>
> Perhaps the only thing that would be useful when it comes to lists,  
> is a
> quick way to check the list contains only a single item, since I'm
> finding this to be a common scenario in my views (e.g. plurality
> wording, deciding to render as a single item or list). In my view, it
> would fall into the same category as rest(), first(), last(),  
> length(),
> etc ... maybe something like single(). Just an idea ... for now, using
> rest() works just fine for me, though I wonder about the overhead.

Yep, we need "shape" operators.

>
>
> That brings up a side question: does rest() construct a new enumerable
> object in the background via shallow copy and iterate over that, or  
> does
> it use the existing collection and iterates over it by skipping the
> first item? Just curious.

I believe it's a new iterator.
Ter


More information about the stringtemplate-interest mailing list