[stringtemplate-interest] bug in first function or just a Java5 issue?

Terence Parr parrt at cs.usfca.edu
Sun Oct 22 12:41:07 PDT 2006


On Oct 20, 2006, at 8:28 PM, John Snyders wrote:
>> Is there such a thing?  How can it have multiple values if empty?  I
>> think what you are saying is that you passed in an object that is a
>> list or something but it has no values.
>
> Yes anything iterable or a collection or ArrayList etc can be empty  
> but it
> is still a collection (I mean collection in the loose sense so as  
> to include
> iterable).

Hmm...well, technically that does not make it multi-valued for ST.   
That is a single object.

> I interpret "multiple valued" as meaning can be iterated over  
> regardless of
> how many things it actually has in it right now.

Well, it's more like "did you do more than one setAttribute", though  
it collapses repeated list additions I think.

>> If that is the case, it
>> should still decide that it is iteratable and then get a null first
>> entry.
>
> This is exactly what I think once it is determined that it can be  
> iterataed

Could be the iterable thing from 1.5 again.

> over it should never go back and treat it like a scalar value. But  
> it does
> as you can see if the if branch  if has next is not taken then it  
> returns
> the original attribute not the first (which would be null because the
> collection is empty) item of the iterator.
>
> I made a change to first and last I can post them if there is any  
> interest.
>
>> what exactly are you passing in?
>
> public class MyCollectionLikeThing implements Iterable

Ah. that is why it's not iterating...that's a 1.5 only thing.
Ter



More information about the stringtemplate-interest mailing list