[stringtemplate-interest] ST 3.1 release imminent

John Snyders jjsnyders at rcn.com
Thu Nov 15 15:34:55 PST 2007


Thanks for adding things to the bug tracker
Comments inline
-John

Terence Parr wrote:
> On Nov 14, 2007, at 9:12 PM, John Snyders wrote:
>
>   
>> Something like Java 5 Iterable must be passed instead. I wrote  
>> about this here:
>> http://www.antlr.org:8080/pipermail/stringtemplate-interest/2007- 
>> May/001073.html
>> http://www.antlr.org:8080/pipermail/stringtemplate-interest/2007- 
>> May/001074.html
>> The problem of "using a list up" is also mentioned here
>> http://www.antlr.org:8080/pipermail/stringtemplate-interest/2007- 
>> January/000915.html
>>     
>
> Do you have a solution?  I'm all ears :)
>   
Yes I think the solution is similar to what Java did with Iterable in 
order to support for each loops. Iterable is
an interface implemented by all reasonable collections so that you can 
repeatedly ask it for an iterator.

If ST didn't need to support 1.4 then I would say just pass the Iterable 
interface around.
What we can do is create a wrapper object that holds a reference to the 
collection and has a method
called (for example) getIterator that will get the iterator from the 
underlying collection.

This is from memory but somewhere there is a method or two that turns 
arrays, collections etc. into iterators. This code needs to change to 
return this STIterable (or what ever you want to call it) wrapper. All 
the code that uses an iterator needs to use this to get the iterator. It 
may be worth considering not allowing iterator to be passed in to ST at 
all. Or at least a warning in the documentation.


>> It is a coincident that just this weekend  I was trying to use ST  
>> on a quick  project to create some address labels from a CSV file.  
>> I was going to turn the CSV file into JSON  (using python) and use  
>> STST from the command line. The trouble is that the address label  
>> document (OOo XML) was a table and the first column needed to be  
>> different than the first. This meant using the first and rest  
>> functions on a list that was passed as a parameter to a template.  
>> The above bug made it impossible to do what I wanted. Sadly I had  
>> to fall back on XML and XSLT.
>>     
>
> I'm eager to fix this.  Perhaps we simply copy the data?  Expensive.
>   
Yes too expensive. Wrap it as described above.
>> I also think that there should be a bug report to Remove definition  
>> of INT from the grammar.
>>     
>
> http://www.antlr.org:8888/browse/ST-31
>
> which grammar is it?
>
>   
action.g
INT :   ('0'..'9')+ ;

>> Any interest in including STST in the distribution?
>>     
>
> sure.
>   
Cool. You can grab it from here
http://hardlikesoftware.com/weblog/stst/
Let me know if you need me to do anything to get it ready.
>   
>> I'll mention some other feature requests just in case they were  
>> forgotten. I know that 3.1 is just a point release.
>>
>> Support programming in the large by allowing .stg and .st files to  
>> refer to other .stg and .st files.
>>
>> List comprehensions?
>> http://www.antlr.org:8080/pipermail/stringtemplate-interest/2007- 
>> June/001116.html
>>
>> List slice?
>> http://www.antlr.org:8080/pipermail/stringtemplate-interest/2007- 
>> June/001090.html
>>     
>
> I'd rather not add this w/o more thought.
>   
I agree that all the rest of this stuff is for future consideration. 
Just wanted it recorded.


More information about the stringtemplate-interest mailing list