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

Nathan Bubna commented on VELOCITY-684:
---------------------------------------

Yuck.  You're right, it's more complicated than i thought.  Considering your 
example, it seems that when a literal of these types is passed in as an 
argument, we probably should keep it as pass by name until a #set happens that 
involves that argument reference.  Then, we can assume that the user is no 
longer wanting to treat it as pass-by-name, so we get the value of it and 
assign it directly in the context (local or global) at that point.  Not sure 
how easy that would be to implement, but i think that would be the simplest, 
least surprising thing to do for users.

As for real life use cases, i don't have one myself, but it seems likely that 
Sergiu does, since he is a user and appears to have expected the behavior i 
just described, even despite his strict pass-by-name advocacy in VELOCITY-681.

> 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