jastrachan | 11 Mar 03:02 2005
Picon

Re: NULL and Strings


On 11 Mar 2005, at 00:37, Mark Igra wrote:

> You raise an interesting point -- do you want to change semantics java
> programmers are used to. I would say that you probably *should* change
> semantics if they are known to annoy most of those java programmers.
>
> This seems to be your position on the whole 
> end-of-line/semicolon/closure
> issue & I would venture that suppressing "null" is an easier sell with 
> most
> folks.
>
> It's rare that people actually want to concatenate the string "null" 
> with a
> string, so I don't think changing this rule would change the semantics 
> of
> code people really expected to write.
>
> Even if you disagree with me on that point, there are some new usages 
> in
> groovy that Java programmers might not have strict expectations about.
>
> At minimum it seems that "null" should be suppressed when inserted as 
> an
> expression into a GString. as in
>
> x = null; println "Hello ${x}"
>
> I certainly expected nulls to be suppressed there and was surprised 
> when
> they weren't.
>
> (BTW, I would gladly accept your no NPE proposal as well, but the ->
> operator probably is good enough)
>
> (Also is
>
> def foo=null
>
> in your code below legal? Is that a new JSR groovy syntax?)

Yes.

BTW we could support an extension to the GString syntax borrowed from 
Velocity...

def foo = null
println "Hello $!foo"

which would only print the value of foo if its not-null

James
-------
http://radio.weblogs.com/0112098/


Gmane