[stringtemplate-interest] The length of things
Terence Parr
parrt at cs.usfca.edu
Sat May 14 13:52:09 PDT 2005
On May 10, 2005, at 3:21 PM, Tom Bentley wrote:
>> 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.
True. :)
> 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?).
I guess you're right.
> 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.
To be consistent, I'd have to do it for any iteratable thingie.
> 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.
Well, you test foo.isEmpty by $if(foo)$; zero length things now test
as not there (next release).
> I think you need to include special cases for the Collection
> framework because of its ubiquity.
Yup.
> How would this look in Python though?
Good question. I'm CC'ing Marq. Heh, Marq are you a member of this
list?
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
More information about the stringtemplate-interest
mailing list