You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Jörg Gottschling (JIRA)" <ji...@apache.org> on 2006/11/06 08:51:37 UTC

[jira] Commented: (VELOCITY-406) Improved Syntax for Maps and Collections

    [ http://issues.apache.org/jira/browse/VELOCITY-406?page=comments#action_12447384 ] 
            
Jörg Gottschling commented on VELOCITY-406:
-------------------------------------------

Hm, ... I will have a look at this "Uberspect" and I hope it is not just a wrapper only for initial context objects.

Your comment makes me think, that this map.key syntax ist already part of the language? I do not think so, because I have not seen documentation or even a comment about this, before yours.

By the way: The syntax may be OK. One of the very ugly problems in Groovy (really ugly) is the Map creation syntax, where you can only use key with the same restriction like identifier. That is because they do not use quotation marks.   def groovy = {has : "a very", ugly : "map syntax"}

What you can NOT do:   def groovy = {"has a" : "nice map syntax"}

It is not a map syntax, it is a bean creation syntax.... :-(

So this is also a problem with the map.property syntax. Will a key like "3" work?   #set( $third = $map.3 )   

It's ok for some very commen cases like   #set( $urlParameterValue = $request.parameter )

What i requested was the use of the slice operator, which unifies the syntax for maps an lists
#set( $third = $list[3] )
#set( $third = $map[3] )


> Improved Syntax for Maps and Collections
> ----------------------------------------
>
>                 Key: VELOCITY-406
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-406
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Jörg Gottschling
>            Priority: Minor
>             Fix For: 1.6
>
>
> I would like to see some syntatic sugar for Maps and Collections and perhaps other Objects too. 
> (I have read that there will be a syntax for map literals in 1.5, that's a first step.)
> I want to have something like in groovy: http://groovy.codehaus.org/Collections
> Scroll down to "Slicing with the subscript operator".
> PS: Please do never implement this terrible confusing groovy map bean syntax, where "map.foo" ist equivalent to "map.get("foo")".

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org