Retrospectively, I agree with Christoph's proposals and semantic, but I
also agree with Will that now that we have the
"directive.set.null.allowed" configuration property, the whole debate
seems deprecated. In the thext major Velocity version, this flag should
default to true.

But I found a bug in the current implementation when allowing nulls:

#set( $map = {} )
#set( $map.foo = $bar ) ## $bar is null
## this removes $map from the context!!!

The correct behaviour is IMO to call the setter (setFoo or put) with a
null value.

Digging further... I'll post this to JIRA if I don't correct it soon.


  Claude

Le jeudi 22 novembre 2007 à 10:54 -0800, Will Glass-Husain a écrit :
> I though we already did this for V. 1.5?   (allow #set to accept null).  But
> we left it off for backwards compatibility.
> 
> Check the code.
> 
> WILL
> 
> On Nov 22, 2007 10:01 AM, <[EMAIL PROTECTED]> wrote:
> 
> > Hi Claude,
> >
> > I originally proposed to allow the bang character in the
> > #set( $!bar = $!foo ) directive to:
> > a) avoid logging the null from $!foo (this is current behaviour
> >    when rendering foo)
> > b) allowing setting the context to null with then bang in $!bar
> > I sent a patch many years ago (was rejected, event though it is BC).
> >
> > See the threads at:
> >  "how to set null value"
> >
> > http://mail-archives.apache.org/mod_mbox/velocity-user/200505.mbox/[EMAIL 
> > PROTECTED]
> >
> >  "Quiet reference in set"
> >
> > http://mail-archives.apache.org/mod_mbox/velocity-user/200102.mbox/[EMAIL 
> > PROTECTED]
> >
> > http://mail-archives.apache.org/mod_mbox/velocity-user/200103.mbox/[EMAIL 
> > PROTECTED]
> >
> >  [PATCH] ASTSetDirective to handle a bang
> >
> > http://mail-archives.apache.org/mod_mbox/velocity-dev/200101.mbox/[EMAIL 
> > PROTECTED]
> >
> >  "wish list" (you participated in this thread!)
> >
> > http://mail-archives.apache.org/mod_mbox/velocity-dev/200310.mbox/[EMAIL 
> > PROTECTED]
> >
> > more embedded:
> >
> > Claude Brisson wrote:
> > > Hi dev,
> > >
> > > I'd like to change the behaviour of #set($foo = $evaluates_to_null)
> > >
> > > The current behaviour is to log (debug loglevel) the message "RHS of
> > > #set statement is null...".
> > >
> > > What I'd like to do:
> > >
> > >  - set the loglevel of this message to warn
> >
> > +0
> >
> > >
> > >  - don't log anything if the left reference is quiet, as in
> > >       #set($!foo = $evaluates_to_null)
> > >    (this syntax is already allowed but does nothing special)
> >
> > I proposed here to not log when the bang is on the RHS, conform to the
> > current notation:
> >  #set( $foo = $!null )
> >
> > Using a bang in the LHS, should allow setting the context variable to
> > null:
> >  #set( $!foo = $null )## this may or may not put a warning in the log
> >
> > >
> > > This will allow template coders
> > >  - to anticipate whether an assignment can be null
> >
> > +1
> >
> > >  - to be warned if another assignment is null for a warn loglevel
> > >
> > >
> > > Any objection?
> > >
> > >
> > >   Claude
> > >
> >
> > :) Christoph
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to