velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna (JIRA)" <>
Subject [jira] Commented: (VELOCITY-619) New set modifier so that set only assigns a value when variable is not defined.
Date Wed, 01 Oct 2008 22:32:44 GMT


Nathan Bubna commented on VELOCITY-619:

I have mixed feelings about this.

First, there are some backwards compatibility concerns.  Since #set( $!foo = 2 ) always worked
(though the bang was meaningless), this could break things for people who unwittingly use(d)
that syntax already.   That's not a showstopper, as they had no good reason to do so, but
we would have to make sure to highlight such a change in the changelog, log a debug message
each time, and perhaps even make this configurable.

Second, it feels odd to me that #set( $!foo = 2 ) should work, but not #set( $! = 2
).  Your comments in the patch simply say "it makes no sense", but why not?  It seems like
it's more a matter of being tricky to implement the check for the value.  I think if we were
to do this, it would be best to be as consistent about it as possible.

Anyone else have thoughts about this?

> New set modifier so that set only assigns a value when variable is not defined.
> -------------------------------------------------------------------------------
>                 Key: VELOCITY-619
>                 URL:
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Byron Foster
>         Attachments: setBangModifier_2.patch
> Define a new #set modifier such that a variable is only set if it is not defined, like
> #set($!foo = "bar")
> If the '!' character proceeds the variable foo, then $foo will be set with the value
of "bar" ONLY IF $foo is not defined (is not in the context).  Otherwise if $foo is defined
it will remain unchanged.

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:
For additional commands, e-mail:

View raw message