groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daniel_sun <realblue...@hotmail.com>
Subject Re: Lambda expression for Groovy 3
Date Tue, 18 Oct 2016 16:34:51 GMT
Jochen, lambda expression is fully supported now :)

https://github.com/danielsun1106/groovy-parser/commit/c380e4230ecef350855b9f56a220411635a7ff87

https://github.com/danielsun1106/groovy-parser/blob/master/src/test/resources/core/Lambda_01x.groovy


Cheers,
Daniel.Sun



在 "Jochen Theodorou [via Groovy]" <ml-node+s329449n5736171h59@n5.nabble.com>,2016年10月18日
00:37写道:


On 17.10.2016 17:40, daniel_sun wrote:
> Hi all,
>
>        Lambda expression for Groovy has been completed with a little
> limitation, which is due to the existing closure whose parameter list can be
> ambiguous to lambda expression, e.g. {a -> a} which can be parsed as a
> lambda expression in a block, but we expect it a closure.

I think that limitation is ok

> In order to
> resolve the ambiguities, the parentheses for parameters is a must, e.g.
> *Java8* allows parentheses-less parameter for lambda when the parameter is
> single and without type: e -> e, but *Groovy* only allows parameter with
> parentheses: (e) -> e.
>
>        *Here are some examples for lambda expression for Groovy:*
> assert 9 == [1, 2, 3].stream().map((e) -> e + 1).reduce(0, (r, e) -> r + e)

which means you cannot write
> assert 9 == [1, 2, 3].stream().map(e -> e + 1).reduce(0, (r, e) -> r + e)

which I find not so ok. Here again it would be no problem if it is
recognized as Closure if that is more easy to accomplish.

bye Jochen


________________________________
If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/Lambda-expression-for-Groovy-3-tp5736169p5736171.html
To unsubscribe from Lambda expression for Groovy 3, click here<http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5736169&code=cmVhbGJsdWVzdW5AaG90bWFpbC5jb218NTczNjE2OXwxMTQ2MjE4MjI1>.
NAML<http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://groovy.329449.n5.nabble.com/Lambda-expression-for-Groovy-3-tp5736169p5736176.html
Sent from the Groovy Dev mailing list archive at Nabble.com.
Mime
View raw message