[stringtemplate-interest] "rest" and template recursion

Terence Parr parrt at cs.usfca.edu
Sat May 31 16:39:16 PDT 2008


On May 30, 2008, at 11:05 PM, Sasha Crosland wrote:

> Thanks for the explanation, Terence.  A side-effect-free rest() does  
> seem more in the spirit of StringTemplate, doesn't it?  I vote yes,  
> for what it's worth.
>
> But would you actually need to make a copy of the list data?  If  
> lists are immutable within a template, then couldn't you easily  
> return a lightweight view of the sublist that reads through to the  
> original list, just like with an iterator?

Well, I'd make a shallow copy of the list, but that's n^2/2 to walk a  
list that way, right?  n copies of n-1.  Expensive but should work.   
Sometimes we need nested output.  Sorry about this!!! Shame on me  
making a side effect :(

Ter


More information about the stringtemplate-interest mailing list