[stringtemplate-interest] The length of things

Tom Bentley tom at egressive.com
Tue May 10 15:21:18 PDT 2005


> Yup, you need to have a getLength() method I'm afraid. 

I suspected you might say that ;-)

> For size, it  
> would be convenient to answer size of array but also size of string.   

Getting the length of Strings and the size of Collections does end up 
being the next logical step on this slippery slope.

The difference with arrays is that length is supposedly a public final 
field of an array, so it should work in theory (shouldn't it?).

The String and Collection lengths are certainly 'nice to have', but 
would need a different StringTemplate to the one we have now in order to 
work.

> The problem is that it's ambiguous.  it would also be yet another  place 
> where a type would have to be assumed to resolve the  ambiguity.  But, 
> I'm not ncessarily totally opposed.

FWIW, I think getting the length of an array is a must.

Support for accessing length() and an isEmpty()-like predicate on String 
and size()/isEmpty() on java.util.Collection and java.util.Map would 
also be useful. I think you need to include special cases for the 
Collection framework because of its ubiquity.

How would this look in Python though?

Cheers,

Tom


More information about the stringtemplate-interest mailing list