[stringtemplate-interest] Understanding template recursion
Trevor Strohman
strohman at cs.umass.edu
Wed May 23 17:58:29 PDT 2007
I'm having trouble understanding recursion in templates.
Suppose I have a list called "items" that contains Strings: "a", "b",
"c", "d", and these two templates:
recurse(x) ::= "<x><rest(x):recurse()>"
recurse2(x) ::= "<x><recurse2(rest(x))>"
I expect <recurse(items)> to become:
abcdcdd
and <recurse2(items)> to become:
abcd
However, <recurse(items)> becomes "abcd" and <recurse2(items)> throws
an Exception. What am I misunderstanding?
Also, I notice that functions first, last and rest don't seem to be
first-class citizens in the language. These expressions throw
exceptions:
<if(first(rest(items))>
<first(items).isEnabled>
This has been a problem for me this afternoon. I feel like I must be
misunderstanding the right way to approach recursive template
invocation.
Trevor
More information about the stringtemplate-interest
mailing list