NetBeans support for proposed small language extensions

Guillaume Laforge glaforge at gmail.com
Fri Jan 23 01:01:56 PST 2009


On Thu, Jan 22, 2009 at 12:04 PM, John Rose <John.Rose at sun.com> wrote:
> On Jan 22, 2009, at 1:14 AM, Rémi Forax wrote:
>
> In that case, you don't need '#',  Dynamic."setcar!"(aCons, aValue)
>
> is not ambiguous. It will work with all qualified access to field and
>
> method.
>
> That's what we did in Groovy; it works well there.  Java needs to be a
> little more formal, I think, and make a clear distinction between string
> literals and identifiers.

Interesting, I'm not sure I really understand why Java would need to
be "more formal", and in what way using # would make things more
formal.
I've come to be used to the Groovy way of doing things (but of course
I'm biased), and I quite like this idea (yours!!!) to have "quoted
identifiers".

Currently, in Groovy, the most advertised one is when using single or
double quotes, but actually, Groovy allows different syntaxes:

System.'out'.println "hello"
System."out".println "hello"
System./out/.println "hello"
System.'''out'''.println "hello"
System."""out""".println "hello"

Basically, all String literal forms are allowed.
And we also allow these ones:

System.(out).println "hello"
System.{out}.println "hello"

Which means we can also use some expressions inside like:

System.('o' + 'u' + 't').println "hello"

Of interest as well is that when the String literal is a GString, you
can interpolate variables!

def var = 'out'
System."${var}".println "hello"
System."""${var}""".println "hello"
System./${var}/.println "hello"

We obviously don't need all these forms, but since String and GStrings
are allowed as quoted identifiers, all these forms are possible.

I quite liked the idea of String quoted identifiers, as they really
allow any kind of identifier name to be used, pretty cleanly IMHO, and
I feel the sharp sign is a bit odd in that context. But it's perhaps
just a matter of taste ;-)

-- 
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one



More information about the mlvm-dev mailing list