velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <>
Subject Re: Maps
Date Sat, 31 Aug 2002 12:43:32 GMT
On 8/30/02 8:47 PM, "Daniel Rall" <> wrote:

> Daniel Rall <> writes:
>> "Juozas Baliuka" <> writes:
>>> $myMap[ "key" ]
>>> $myMap[ $var ] 
>> This array index syntax is not supported, as the $myMap object is not
>> an Array object.
> Being very familiar with Perl and Python, I realize that other
> languages do support this sort of syntax for hash lookups.  As
> Velocity is quite Java-centric and has so far explicitly avoided
> anything resembling Perl, I wouldn't really be in favor of adding
> anything like that, either.

This is supported in Jexl, as I was thinking of proposing it here.  ECMA
script seems to require the equivalence of

    a.b  and  a[b]

which to me is mind-bendingly weird as I see structural semantics behind "."
and "[]"  You can do things like


Where foo is an array...  I have to have it in Jexl for compliance with
JSTL's EL (not that Jexl is 100% compliant yet...)...

Anyway, I can make a good argument (to myself anyway) that this fits with
the notion of 'introspective polymorphism', the idea that class doesn't
matter when you say


to be able to be calling either   getBar()    or   get("bar") and be able to
switch the object in the context freely.

This . == [] would take that one step further.

However, I keep coming back to wondering if we can avoid adding [] and still
have the functionality (less syntax is more...), but then we get to things


(cue Jon : "This isn't Perl") to have the same functionality as


I actually wouldn't personally mind an array accessor, as the problem of
accessing out of bounds, which we already have with array lists :

  #set($foo = [1,2,3,4])


wouldn't be a new thing.

Off to coffee..

Geir Magnusson Jr. 
Research & Development, Adeptra Inc.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message