velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: #set silently fails if RHS is null
Date Fri, 09 Nov 2001 18:39:47 GMT
On 11/9/01 11:48 AM, "Sean Legassick" <sean@informage.net> wrote:

> In message <B81043E8.A56A%geirm@optonline.net>, Geir Magnusson Jr.
> <geirm@optonline.net> writes
>> The problem is that this is a 180 degree switch, so it won't do to just
>> throw it in there.  By adding a switch, we can play with it and see if it
>> really solves problems, and it prevents things from going haywire for people
>> if they get a new nightly or something for a bugfix.
> 
> Sure - but I suspect unless people want the behaviour, they'll leave it
> switched off and so the effect won't be tested.
> 
>> I say 'play with it' because the problem can easily be worked around via a
>> tool, but that makes for funny templates.
> 
> But sure it makes it easy to try it both ways.
> 
>> One solution is adding an event handler to let the programmer make the
>> decision...
> 
> That could also do it.
> 
> I don't have a strong view on the behaviour, personally saying that #set
> with a RHS of null removes the object from the context works fine
> conceptually. But I don't particularly mind the current behaviour
> either.
> 
> I do feel strongly though that opening the door to configurable language
> semantics is a bad move, it creates a precedent for people to suggest
> all kinds of little switches and soon it will be impossible to tell what
> a VTL template does just by looking at it.

I agree.  I just want to play with it.

I have abhorred this aspect of things for a long time - I think of it as a
bug in a sense because what happens is that he #set() 'fails' based on data,
which is equally as bad as configurable language semantics...

I.e. Looking at 

#set($bar = "woogie")
#set($bar = $this.couldReturnNull() )

Means I have *no clue* what $bar has.  It could contain the result of the
couldReturnNull() method, or not, and be unchanged.  That¹s weird for an
assignment in any language.

Some would argue the ambiguity of

#if( $foo )

is ok.  I can go both ways on this as if you keep to the original
philosophy, its ok - and it's a trivial solution to do

#if($tool.inContext($foo))

Which makes it really clear what you are trying to figure out...

> 
> (standard $0.02 type disclaimer)

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message