[
https://issues.apache.org/jira/browse/VELOCITY-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12667895#action_12667895
]
Nathan Bubna commented on VELOCITY-687:
---------------------------------------
If people have a switch to flip for this, then when creating macro libraries
you have to consider whether the parameters are being passed by value or by
name. This will require those sharing libraries with others (or their future
selves) to document clearly what is expected of params, or design the macros so
that it doesn't matter (if possible). Definitely more complicated.
And saying it is a changes longstanding behavior doesn't mean that i'm saying
it is right the way it is.
As for performance, i'm far more concerned about my time than runtime.
Velocity is not a bottleneck for me in my apps. Complicating user support,
macro library development, and testing are not happy ideas for me. I'm
developing an allergy to behavior-changing configuration switches and the poor
cost/benefit ratio they often seem to have. The fewer configurable behaviors,
the better. Leave config for constants (like max depths and bodyContent
keys), external interfaces (like resource loaders and loggers) and extension
hooks (like user directives and uberspects).
Again, i'm open to changing how parameters are passed, but *not with a
configuration switch*. We should just decide how we want various things passed
and stick with it. Yes, that is limited in 1.x by concerns about backwards
compatibility, but those are the breaks. If you really want to change this,
you could always kick off a 2.0 branch and just change it outright, no config
switch.
For 1.x, we may be able to get away with passing literals by value (e.g. #foo(
[$a, $b] { 'test': $this } 3 [1..$ten] 'string' ) ) as that's pretty darn
intuitive and unlikely to mess many users up, but right now i think we should
leave all references and interpolated strings as pass by name.
> Macro pass by value option
> --------------------------
>
> Key: VELOCITY-687
> URL: https://issues.apache.org/jira/browse/VELOCITY-687
> Project: Velocity
> Issue Type: New Feature
> Components: Engine
> Affects Versions: 1.7
> Reporter: Byron Foster
> Attachments: value.patch
>
>
> Add a configuration property which would change macro parameter passing from
> pass by name, to pass by value. I think in many instances this option will
> provide behavior that is more intuitive to the user. There are two important
> exceptions to this, references created by #define, and references created by
> BlockMacro's $bodyContent. This allows the user to still specify pass by
> name semantics when desired, for example:
> #define($x) #if($foo)$foo.bar#{else}-None-#end #end
> #go($x)
> In the above example '#if($foo)$foo.bar#{else}-None-#end' will be passed by
> name. In all other cases pass by value rules apply for example:
> #go($foo.bar [1, 2, 3] #if($bar)Yes#{else}No#end)
> In the above example all parameters will be evaluated to a value first, then
> passed to #go. This has potential performance improvements also.
--
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]