[ 
https://issues.apache.org/jira/browse/VELOCITY-684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12666596#action_12666596
 ] 

Byron Foster commented on VELOCITY-684:
---------------------------------------

I don't mean to sound technically rigid, and I would be for any simple 
shortcut.  An obvious solution is to make ASTMaps constant, but it's not so 
simple. for example I can have this:

#macro(foo $map)
  #set($b = "c")
  #set($map.x = "z")
  $map.a $map.x
#end

#foo({'a' : $b, 'x' : 'y'})

A strait forward constant implementation gives:  "$map.a z"  (in strict mode 
you get an exception)
As it stands you get: "c y"

I'm not sure what the solution is in this context.  Also, this same issues 
applies to ASTObjectArray, ASTIntegerRange, etc...



> Passing a map literal to a macro call forbids altering the map in any way, 
> while maps bound to an actual parameter may be changed
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-684
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-684
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.6.1
>            Reporter: Sergiu Dumitriu
>
> For example, with the following macro:
> #macro(changeMap $map)
>   Before: $map.someKey
>   #set($map.someKey = 'new value')
>   After: $map.someKey
> #end
> This call works as expected:
> #set($actualMap = {'someKey' : 'old value'})
> #changeMap($actualMap) => old value, then new value
> But this one doesn't:
> #changeMap({'someKey' : 'old value'}) => old value, then again old value

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to