Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C9264200BA6 for ; Tue, 18 Oct 2016 20:21:43 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C7AE5160AE5; Tue, 18 Oct 2016 18:21:43 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C1C53160ACE for ; Tue, 18 Oct 2016 20:21:42 +0200 (CEST) Received: (qmail 59439 invoked by uid 500); 18 Oct 2016 18:21:42 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 59421 invoked by uid 99); 18 Oct 2016 18:21:41 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Oct 2016 18:21:41 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 9FEAA1A03C4 for ; Tue, 18 Oct 2016 18:21:40 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.192 X-Spam-Level: *** X-Spam-Status: No, score=3.192 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id di3vKCaH14UV for ; Tue, 18 Oct 2016 18:21:38 +0000 (UTC) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 939C65F39A for ; Tue, 18 Oct 2016 18:21:37 +0000 (UTC) Received: by mail-wm0-f49.google.com with SMTP id c78so10279351wme.0 for ; Tue, 18 Oct 2016 11:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=/EmlQJZrNoueo3UlKgNI8PGdQ8i+BVmx4MbbJsxmiRc=; b=gi3OSAGM3ZdJJDECZxaDH8MKLYEFddLdgHKDES+idBU/+rBeGdNL5/9Dz7APmNXjd6 x1MuY7I2uFlEELbvLYqZ/19a98TgkKStwfvv/WAXRU9mWxOIJVPJw9H3orra55RVwf48 hDL3U9rpWak5rrWugXtjIrY0L3Udk2nTTOKe6jRyL+SjRB9UjaTkATVzeyzOrVPZLu9a 4XU4SShIFGwUHYBt5+7p9Vfm1Q391leDTULbhhm4WM9WuGd2g9/dpYddH/BqSgzTux7V YOCq/M29XUqGhnZuHfsA8+matchN+/dH+H5jABMNMUCQOYXOYZlFplJeAOyKU8wdUoR9 LEdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=/EmlQJZrNoueo3UlKgNI8PGdQ8i+BVmx4MbbJsxmiRc=; b=k4+1SrfwGOBz6R9BwsI0kuQwYj27Be6MwmCkVR4fOE1mk6VYTpkr+4qV+3lu+oOGzv 9VpGnu/HxXd8gmhFeRLaQf5V7BkpYLYWwZc1e613nzo+pJRVAJ2ANz10Kb+o1hly/hTc CV8NOuEPJ8b0n1Fy/W99U09oVH6VIyvBLd/1e5NlGEXoODPqhYgr1iy2MgBitNpSTaYf ZmYThhCl0DiqrkqbHfrV3WIjgHjhBWsN9QavFLmnhDu1dAWdFBBnB1+o1OaA9i6gso69 0fWmI8tZPv4xqcSb5z2Jz7OOP1dNkC9YzoPzBM3vQTTPN9o8CX/b6hiXUgb2BaM90a8Q iR3A== X-Gm-Message-State: AA6/9Rmu+RNRlqYkmD3nRfDpbCZsN5ZcHAS6o+mUBhKnvMYNmC3ZDEd4ROIJ9QJmfdYfcOLYJ7gkRErIf64D+g== X-Received: by 10.28.102.9 with SMTP id a9mr13520084wmc.10.1476814894895; Tue, 18 Oct 2016 11:21:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.44.38 with HTTP; Tue, 18 Oct 2016 11:21:34 -0700 (PDT) In-Reply-To: <58065EF3.80504@gmx.org> References: <1476718854771-5736169.post@n5.nabble.com> <58065EF3.80504@gmx.org> From: Guillaume Laforge Date: Tue, 18 Oct 2016 20:21:34 +0200 Message-ID: Subject: Re: Lambda expression for Groovy 3 To: dev@groovy.apache.org Content-Type: multipart/alternative; boundary=001a114b315035974c053f27c3f3 archived-at: Tue, 18 Oct 2016 18:21:44 -0000 --001a114b315035974c053f27c3f3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Is it actually Groovy closures? or "real" Java lambdas? On Tue, Oct 18, 2016 at 7:42 PM, Jochen Theodorou wrote= : > > hah, I knew you can do it ;) > > On 18.10.2016 18:34, daniel_sun wrote: > >> Jochen, lambda expression is fully supported now :) >> >> https://github.com/danielsun1106/groovy-parser/commit/c380e4 >> 230ecef350855b9f56a220411635a7ff87 >> >> https://github.com/danielsun1106/groovy-parser/blob/master/ >> src/test/resources/core/Lambda_01x.groovy >> >> >> Cheers, >> Daniel.Sun >> >> >> >> =E5=9C=A8 "Jochen Theodorou [via Groovy]" > >=EF=BC=8C2016=E5= =B9=B410=E6=9C=8818=E6=97=A5 00:37 >> >> =E5=86=99=E9=81=93=EF=BC=9A >> >> >> >> 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 =3D=3D [1, 2, 3].stream().map((e) -> e + 1).reduce(0, (r= , e) >> -> r + e) >> >> which means you cannot write >> > assert 9 =3D=3D [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. >> NAML >> > jtp?macro=3Dmacro_viewer&id=3Dinstant_html%21nabble%3Aemail. >> naml&base=3Dnabble.naml.namespaces.BasicNamespace-nabble.view.web.templa= te. >> NabbleNamespace-nabble.view.web.template.NodeNamespace& >> breadcrumbs=3Dnotify_subscribers%21nabble%3Aemail. >> naml-instant_emails%21nabble%3Aemail.naml-send_instant_ >> email%21nabble%3Aemail.naml> >> >> >> >> ------------------------------------------------------------------------ >> View this message in context: Re: Lambda expression for Groovy 3 >> > Groovy-3-tp5736169p5736176.html> >> Sent from the Groovy Dev mailing list archive >> at >> Nabble.com. >> > > --=20 Guillaume Laforge Apache Groovy committer & PMC Vice-President Developer Advocate @ Google Cloud Platform Blog: http://glaforge.appspot.com/ Social: @glaforge / Google+ --001a114b315035974c053f27c3f3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Is it actually Groovy closures? or "real" Java l= ambdas?

On T= ue, Oct 18, 2016 at 7:42 PM, Jochen Theodorou <blackdrag@gmx.org> wrote:

hah, I knew you can do it ;)

On 18.10.2016 18:34, daniel_sun wrote:
Jochen, lambda expression is fully supported now :)

https:= //github.com/danielsun1106/groovy-parser/commit/c380e4230ecef3508= 55b9f56a220411635a7ff87

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


Cheers,
Daniel.Sun



=E5=9C=A8 "Jochen Theodorou [via Groovy]" <ml-node+[hidden ema= il]
</user/SendEmail.jtp?type=3Dnode&node=3D5736176&i=3D0>&g= t;=EF=BC=8C2016=E5=B9=B410=E6=9C=8818=E6=97=A5 00:37

=E5=86=99=E9=81=93=EF=BC=9A



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

=C2=A0 =C2=A0 I think that limitation is ok

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

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

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

=C2=A0 =C2=A0 bye Jochen


=C2=A0 =C2=A0 --------------------------------------------------------= ----------------
=C2=A0 =C2=A0 If you reply to this email, your message will be added to the=
=C2=A0 =C2=A0 discussion below:
=C2=A0 =C2=A0 http://groovy.329449.n5.nabble.com/Lambda-expression-for-Groovy= -3-tp5736169p5736171.html

=C2=A0 =C2=A0 To unsubscribe from Lambda expression for Groovy 3, click her= e.
=C2=A0 =C2=A0 NAML
=C2=A0 =C2=A0 <http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=3Dmacro_viewer&id=3Dinstant_html%21nabble%3Aemail.naml&base=3Dnabble.naml.namespaces.BasicNamespace-nabble.vi= ew.web.template.NabbleNamespace-nabble.view.web.template.NodeName= space&breadcrumbs=3Dnotify_subscribers%21nabble%3Aemail.= naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21na= bble%3Aemail.naml>



-----------------------------------------------------------------= -------
View this message in context: Re: Lambda expression for Groovy 3
<http://g= roovy.329449.n5.nabble.com/Lambda-expression-for-Groovy-3-tp57361= 69p5736176.html>
Sent from the Groovy Dev mailing list archive
<http://groovy.329449.n5.nabble.co= m/Groovy-Dev-f372993.html> at Nabble.com.




--
Guillaume Laforge
Apache Groovy committer & P= MC Vice-President
Developer Advocate @ Google Cloud P= latform

Blog:=C2=A0http://glaforge.appspot.com/
Social:= @glaforge=C2= =A0/ Google+
=
--001a114b315035974c053f27c3f3--