Re: Lambda expression for Groovy 3

2016-10-19 Thread Jochen Theodorou
On 19.10.2016 12:21, Remi Forax wrote: [...] The main issue i see of having one semantics is that the meaning of 'this' in a Groovy closure means the closure itself while 'this' in a Java lambda means the enclosing object, so { -> this } in Groovy is a substitute to () -> this in Java. that is

Re: Lambda expression for Groovy 3

2016-10-19 Thread daniel_sun
___ De: "Cédric Champeau" <[hidden email]> À: [hidden email] Envoyé: Mercredi 19 Octobre 2016 09:09:51 Objet: Re: Lambda expression for Groovy 3 First of all, great work, Daniel ! I'm confident that making the "lambdas" be "closures&quo

Re: Lambda expression for Groovy 3

2016-10-19 Thread daniel_sun
Hi Jochen, Thanks for your detail explanation. I'll try to implement the method reference for Groovy 3 :) Cheers, Daniel.Sun -- View this message in context: http://groovy.329449.n5.nabble.com/Lambda-expression-for-Groovy-3-tp5736169p5736212.html Sent from the Groovy Dev mailing

Re: 答复: Lambda expression for Groovy 3

2016-10-19 Thread Jochen Theodorou
On 19.10.2016 14:12, daniel_sun wrote: Hi Rémi, Groovy can choose the right method to call :) assert ['1', '2', '3'] == [1, 2, 3].collect(Integer.&toString) I am sure that works only because the static Integer.toString(int) and the virtual Integer.toString() return the same values. If

Re: Lambda expression for Groovy 3

2016-10-19 Thread Jochen Theodorou
On 19.10.2016 12:34, Jesper Steen Møller wrote: Hi Daniel Be careful with that approach, as it won’t work for static methods — leading to very different semantics for the two languages. Also, you won’t be able to support constructor references without some new AST construct, I guess. Norma

Re: Lambda expression for Groovy 3

2016-10-19 Thread Jochen Theodorou
On 19.10.2016 12:26, Cédric Champeau wrote: 2016-10-19 10:51 GMT+02:00 Jochen Theodorou mailto:blackd...@gmx.org>>: On 19.10.2016 09:09, Cédric Champeau wrote: First of all, great work, Daniel ! I'm confident that making the "lambdas" be "closures" in Groovy is enough.

Re: Lambda expression for Groovy 3

2016-10-19 Thread Jochen Theodorou
On 19.10.2016 12:23, daniel_sun wrote: Hi Jochen, I plan to map Java's *::* to Groovy's *.&*, the following code is ok now. What do you think about it? [1, 2, 3].stream().forEach(System.out.&println) // object method, [1, 2, 3].stream().forEach(System.out::println) [1, 2, 3].st

答复: Lambda expression for Groovy 3

2016-10-19 Thread daniel_sun
Hi Rémi, Groovy can choose the right method to call :) assert ['1', '2', '3'] == [1, 2, 3].collect(Integer.&toString) Cheers, Daniel.Sun 发件人: Remi Forax [via Groovy] 发送时间: 2016年10月19日 19:29 收件人: daniel_sun 主题: Re: Lamb

Re: Lambda expression for Groovy 3

2016-10-19 Thread Remi Forax
nt). Rémi - Mail original - > De: "daniel_sun" > À: d...@groovy.incubator.apache.org > Envoyé: Mercredi 19 Octobre 2016 12:23:09 > Objet: Re: Lambda expression for Groovy 3 > Hi Jochen, > > I plan to map Java's *::* to Groovy's *.&*, the

Re: Lambda expression for Groovy 3

2016-10-19 Thread Remi Forax
Hi Cedric, > De: "Cédric Champeau" > À: dev@groovy.apache.org > Envoyé: Mercredi 19 Octobre 2016 09:09:51 > Objet: Re: Lambda expression for Groovy 3 > First of all, great work, Daniel ! I'm confident that making the "lambdas" be > "closures&q

Re: Lambda expression for Groovy 3

2016-10-19 Thread daniel_sun
GenericsType[]::new Thanks for your reminding :) Cheers, Daniel.Sun -- View this message in context: http://groovy.329449.n5.nabble.com/Lambda-expression-for-Groovy-3-tp5736169p5736201.html Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Lambda expression for Groovy 3

2016-10-19 Thread forax
> De: "Jesper Steen Møller" > À: dev@groovy.apache.org > Cc: "Remi Forax" > Envoyé: Mercredi 19 Octobre 2016 01:15:47 > Objet: Re: Lambda expression for Groovy 3 > "Real lambdas" with the full invokedynamic treatment is a big job, and > requir

Re: Lambda expression for Groovy 3

2016-10-19 Thread Paul King
object method, >> [1, 2, 3].stream().forEach(System.out::println) >> [1, 2, 3].stream().forEach(Objects.&requireNonNull) // class method, [1, >> 2, >> 3].stream().forEach(Objects::requireNonNull) >> >> Cheers, >> Daniel.Sun >> >> >> >

Re: Lambda expression for Groovy 3

2016-10-19 Thread Jesper Steen Møller
rintln) > [1, 2, 3].stream().forEach(Objects.&requireNonNull) // class method, [1, 2, > 3].stream().forEach(Objects::requireNonNull) > > Cheers, > Daniel.Sun > > > > -- > View this message in context: > http://groovy.329449.n5.nabble.com/Lambda-expression-f

Re: Lambda expression for Groovy 3

2016-10-19 Thread Cédric Champeau
2016-10-19 10:51 GMT+02:00 Jochen Theodorou : > > > On 19.10.2016 09:09, Cédric Champeau wrote: > >> First of all, great work, Daniel ! I'm confident that making the >> "lambdas" be "closures" in Groovy is enough. >> > > I think it won't be enough for :: and MethodClosures. Actually, Daniel, > are

Re: Lambda expression for Groovy 3

2016-10-19 Thread Guillaume Laforge
p;requireNonNull) // class method, [1, > 2, > 3].stream().forEach(Objects::requireNonNull) > > Cheers, > Daniel.Sun > > > > -- > View this message in context: http://groovy.329449.n5. > nabble.com/Lambda-expression-for-Groovy-3-tp5736169p5736195.html > Sent from the Groovy D

Re: Lambda expression for Groovy 3

2016-10-19 Thread daniel_sun
ts.&requireNonNull) // class method, [1, 2, 3].stream().forEach(Objects::requireNonNull) Cheers, Daniel.Sun -- View this message in context: http://groovy.329449.n5.nabble.com/Lambda-expression-for-Groovy-3-tp5736169p5736195.html Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Lambda expression for Groovy 3

2016-10-19 Thread Jochen Theodorou
On 19.10.2016 09:09, Cédric Champeau wrote: First of all, great work, Daniel ! I'm confident that making the "lambdas" be "closures" in Groovy is enough. I think it won't be enough for :: and MethodClosures. Actually, Daniel, are those supported in the new Grammar and what are they mapped to

Re: Lambda expression for Groovy 3

2016-10-19 Thread Cédric Champeau
First of all, great work, Daniel ! I'm confident that making the "lambdas" be "closures" in Groovy is enough. I stated it in the past but I'm going to repeat myself here, I don't think having 2 syntax for "closures/lambdas" with slightly different semantics would help our users/language. That said,

Re: Lambda expression for Groovy 3

2016-10-18 Thread daniel_sun
n below: http://groovy.329449.n5.nabble.com/Lambda-expression-for-Groovy-3-tp5736169p5736191.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=cmVhbGJsdWVzdW5AaG90bWFpb

Re: Lambda expression for Groovy 3

2016-10-18 Thread Jochen Theodorou
On 19.10.2016 02:49, daniel_sun wrote: The new parser is based on Java8, so it has to target to Groovy3. As far I know, there are some amazing features under development or test, e.g. MOP2, new Joint compiler, Macro(appears at the snapshot of 2.5.0), etc. Looking forward to them :) (a) I think

Re: Lambda expression for Groovy 3

2016-10-18 Thread daniel_sun
re 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

Re: Lambda expression for Groovy 3

2016-10-18 Thread Guillaume Laforge
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. >>>>

Re: Lambda expression for Groovy 3

2016-10-18 Thread daniel_sun
nd 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

Re: Lambda expression for Groovy 3

2016-10-18 Thread daniel_sun
___ 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-tp5736169p5736182.html To unsubscribe from Lambda expression for Groovy 3, click here<http://groovy.3

Re: Lambda expression for Groovy 3

2016-10-18 Thread daniel_sun
- 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 h

Re: Lambda expression for Groovy 3

2016-10-18 Thread Guillaume Laforge
ameter 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) >>>> -&g

Re: Lambda expression for Groovy 3

2016-10-18 Thread daniel_sun
n 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-

Re: Lambda expression for Groovy 3

2016-10-18 Thread daniel_sun
l, 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. NAML <http://groovy.329449.n5.nabble.com/template/NamlSer

Re: Lambda expression for Groovy 3

2016-10-18 Thread Roman Shaposhnik
On Tue, Oct 18, 2016 at 4:15 PM, Jesper Steen Møller wrote: > "Real lambdas" with the full invokedynamic treatment is a big job, and > requires static type inference. > Given that Groovy can already coerce closures into functional interfaces > (dynamically), we could implement the whole metafactor

Re: Lambda expression for Groovy 3

2016-10-18 Thread Jesper Steen Møller
>>> > *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

Re: Lambda expression for Groovy 3

2016-10-18 Thread Guillaume Laforge
; 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

Re: Lambda expression for Groovy 3

2016-10-18 Thread Remi Forax
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 -&g

Re: Lambda expression for Groovy 3

2016-10-18 Thread Guillaume Laforge
gt; > 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) >> >>

Re: Lambda expression for Groovy 3

2016-10-18 Thread Jochen Theodorou
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 discussio

Re: Lambda expression for Groovy 3

2016-10-18 Thread daniel_sun
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&nod

Re: Lambda expression for Groovy 3

2016-10-17 Thread daniel_sun
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-express

Re: Lambda expression for Groovy 3

2016-10-17 Thread Jochen Theodorou
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,

Lambda expression for Groovy 3

2016-10-17 Thread daniel_sun
s, Daniel.Sun -- View this message in context: http://groovy.329449.n5.nabble.com/Lambda-expression-for-Groovy-3-tp5736169.html Sent from the Groovy Dev mailing list archive at Nabble.com.