[stringtemplate-interest] auto-flattening lists
John Snyders
jjsnyders at rcn.com
Fri Nov 9 08:34:38 PST 2007
Thanks for entering a bug for this.
Even though |$table(t=[ [ "a", "b" ], [ "c", "d" ] ])$| is allowed
it gets flattened.
The bug isn't explicit about what the expected fix is. Perhaps it is
obvious but I'll say it anyway.
My expectation is that the t argument to the table template be set to a
list which contains two elements
the first being a list of elements "a" and "b" and the second being a
list of elements "c" and "d".
The blog post is all about the data model of ST and has nothing to say
about Java API calls
such as setAttribute. Am I correct that the use you are asking about is
where setAttribute is
used to build up a list item by item? I don't think I used that pattern
much. I tend to have a
fully formed data structure already and then just do one setAttribute
for it.
I think that the setAttribute behavior is correct
// myList is "a","b"
// myOther list is "c", "d"
setAttribute(foo, myList)
setAttribute(foo, myOtherList)
setAttribute(foo, "e")
// should result in foo being the list "a", "b", "c", "d", "e"
If you want deep structure to your attributes just build it first then
call setAttribute once.
-John
Terence Parr wrote:
> Hi, added a bug
>
> http://www.antlr.org:8888/browse/ST-29
>
> mentioned by John Synders at
>
> http://hardlikesoftware.com/weblog/2007/06/01/thoughts-on-
> stringtemplate-part-1/
>
> I note in my code this for setAttribute:
>
> * If you send in a List plus other values to the same
> * attribute, they all get flattened into one List of values.
> * This will be a new list object so that incoming objects are
> * not altered.
>
> What is correct functionality? If you send in a list of names and
> then "Ter", should it add "Ter" to the list or should the attribute
> be a 2-element list with a list as first element and string as 2nd?
>
> Ter
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
>
More information about the stringtemplate-interest
mailing list