You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Claude Brisson <cl...@renegat.net> on 2007/11/22 15:30:15 UTC

#set warning if null

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

 - 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)

This will allow template coders
 - to anticipate whether an assignment can be null
 - to be warned if another assignment is null for a warn loglevel


Any objection?


  Claude



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: #set warning if null

Posted by Claude Brisson <cl...@renegat.net>.
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, <ap...@recks.org> 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/%3c4275E7D2.1000706@dlr.de%3e
> >
> >  "Quiet reference in set"
> >
> > http://mail-archives.apache.org/mod_mbox/velocity-user/200102.mbox/%3c3A9A1C09.88FD8901@dlr.de%3e
> >
> > http://mail-archives.apache.org/mod_mbox/velocity-user/200103.mbox/%3c3AA5EE7E.564E956A@dlr.de%3e
> >
> >  [PATCH] ASTSetDirective to handle a bang
> >
> > http://mail-archives.apache.org/mod_mbox/velocity-dev/200101.mbox/%3c3A62CABF.121C12E5@dlr.de%3e
> >
> >  "wish list" (you participated in this thread!)
> >
> > http://mail-archives.apache.org/mod_mbox/velocity-dev/200310.mbox/%3c3F9632BA.9010703@dlr.de%3e
> >
> > 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: dev-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: dev-help@velocity.apache.org
> >
> >
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: #set warning if null

Posted by Will Glass-Husain <wg...@gmail.com>.
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, <ap...@recks.org> 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/%3c4275E7D2.1000706@dlr.de%3e
>
>  "Quiet reference in set"
>
> http://mail-archives.apache.org/mod_mbox/velocity-user/200102.mbox/%3c3A9A1C09.88FD8901@dlr.de%3e
>
> http://mail-archives.apache.org/mod_mbox/velocity-user/200103.mbox/%3c3AA5EE7E.564E956A@dlr.de%3e
>
>  [PATCH] ASTSetDirective to handle a bang
>
> http://mail-archives.apache.org/mod_mbox/velocity-dev/200101.mbox/%3c3A62CABF.121C12E5@dlr.de%3e
>
>  "wish list" (you participated in this thread!)
>
> http://mail-archives.apache.org/mod_mbox/velocity-dev/200310.mbox/%3c3F9632BA.9010703@dlr.de%3e
>
> 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: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>


-- 
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

Re: #set warning if null

Posted by ap...@recks.org.
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/%3c4275E7D2.1000706@dlr.de%3e

  "Quiet reference in set"
  http://mail-archives.apache.org/mod_mbox/velocity-user/200102.mbox/%3c3A9A1C09.88FD8901@dlr.de%3e
  http://mail-archives.apache.org/mod_mbox/velocity-user/200103.mbox/%3c3AA5EE7E.564E956A@dlr.de%3e

  [PATCH] ASTSetDirective to handle a bang
  http://mail-archives.apache.org/mod_mbox/velocity-dev/200101.mbox/%3c3A62CABF.121C12E5@dlr.de%3e

  "wish list" (you participated in this thread!)
  http://mail-archives.apache.org/mod_mbox/velocity-dev/200310.mbox/%3c3F9632BA.9010703@dlr.de%3e

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: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: #set warning if null

Posted by Nathan Bubna <nb...@gmail.com>.
On Nov 22, 2007 6:30 AM, Claude Brisson <cl...@renegat.net> 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
>
>  - 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)
>
> 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

-0  it still seems like it's mostly a debugging issue.



> Any objection?
>
>
>   Claude
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org