16 May 12:08
Re: [groovy-user] Oddities in the grammar that effect DSL writing
From: Jochen Theodorou <blackdrag@...>
Subject: Re: [groovy-user] Oddities in the grammar that effect DSL writing
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-05-16 10:08:39 GMT
Subject: Re: [groovy-user] Oddities in the grammar that effect DSL writing
Newsgroups: gmane.comp.lang.groovy.user
Date: 2008-05-16 10:08:39 GMT
melix schrieb:
> That's right and it must be the reason why I feel it more natural :)
>
> However, today I do things like this (syntactically valid in Groovy) :
>
> import static com.lingway.Utils.*;
>
> ...
>
> select { node.do(it) }?.store()
>
> ..
>
> select is a primitive (statically imported method) which injects a closure
> (it) to the do() method. The fun thing is the last part of the expression,
> which means "if the select primitive returns something, then call the method
> store() on the result". It's something I'm heavily using in my DSL. If the
> behaviour of Groovy was changed so that it looks like functional programming
> languages when dropping parenthesis, then it would be interpreted like this
> :
>
> select({ node.do(it) }?.store())
>
> However, I think I can live with the following syntax, which IMHO is less
> disturbing :
>
> (select { node.doi(t) })?.store()
but in a GPath...?
nodes.first.findAll{it.prop='11'}.each{println it}
that would have to become:
(nodes.first.findAll{it.prop='11'}).each{println it}
or
nodes.first.findAll({it.prop='11'}).each{println it}
or it is whitespace sensitive...
bye blackdrag
--
--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
RSS Feed