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 F21AF200BA5 for ; Wed, 19 Oct 2016 13:17:35 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F0AA3160AEA; Wed, 19 Oct 2016 11:17:35 +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 410C0160ADE for ; Wed, 19 Oct 2016 13:17:35 +0200 (CEST) Received: (qmail 29920 invoked by uid 500); 19 Oct 2016 11:17:34 -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 29906 invoked by uid 99); 19 Oct 2016 11:17:33 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Oct 2016 11:17:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 0E141C0595 for ; Wed, 19 Oct 2016 11:17:33 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.301 X-Spam-Level: ** X-Spam-Status: No, score=2.301 tagged_above=-999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=2, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id P-aZVIICccvm for ; Wed, 19 Oct 2016 11:17:30 +0000 (UTC) Received: from smtpout01.partage.renater.fr (smtpout01.partage.renater.fr [194.254.240.31]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 2C49A5FBF7 for ; Wed, 19 Oct 2016 11:17:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtpout01.partage.renater.fr (Postfix) with ESMTP id 091D9AC1C7 for ; Wed, 19 Oct 2016 13:17:29 +0200 (CEST) Received: from smtpout01.partage.renater.fr ([127.0.0.1]) by localhost (smtpout01.partage.renater.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QUAciz9JIxXJ for ; Wed, 19 Oct 2016 13:17:23 +0200 (CEST) Received: from zmtaout01.partage.renater.fr (zmtaout01.partage.renater.fr [194.254.240.30]) by smtpout01.partage.renater.fr (Postfix) with ESMTP id 99637AC4CD for ; Wed, 19 Oct 2016 13:17:21 +0200 (CEST) Received: from zmtaout01.partage.renater.fr (localhost [127.0.0.1]) by zmtaout01.partage.renater.fr (Postfix) with ESMTPS id 144EF1A084A for ; Wed, 19 Oct 2016 12:21:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zmtaout01.partage.renater.fr (Postfix) with ESMTP id 07CDF1A0885 for ; Wed, 19 Oct 2016 12:21:39 +0200 (CEST) X-Virus-Scanned: amavisd-new at zmtaout01.partage.renater.fr Received: from zmtaout01.partage.renater.fr ([127.0.0.1]) by localhost (zmtaout01.partage.renater.fr [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id BlAQVUKf2mxY for ; Wed, 19 Oct 2016 12:21:38 +0200 (CEST) Received: from zstore27-staff.partage.renater.fr (zstore27-staff.partage.renater.fr [10.254.241.53]) by zmtaout01.partage.renater.fr (Postfix) with ESMTP id E76A31A084A for ; Wed, 19 Oct 2016 12:21:38 +0200 (CEST) Date: Wed, 19 Oct 2016 12:21:38 +0200 (CEST) From: Remi Forax To: dev@groovy.apache.org Message-ID: <1778916372.1257597.1476872498892.JavaMail.zimbra@u-pem.fr> In-Reply-To: References: <1476718854771-5736169.post@n5.nabble.com> <5806CC8E.2080308@gmx.org> Subject: Re: Lambda expression for Groovy 3 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1257596_630114099.1476872498891" X-Originating-IP: [194.254.242.1] X-Mailer: Zimbra 8.6.0_GA_1200 (ZimbraWebClient - FF48 (Linux)/8.6.0_GA_1200) Thread-Topic: Lambda expression for Groovy 3 Thread-Index: XgbCoAGo8GhIoyRv/KM7y9QHRTjlFg== archived-at: Wed, 19 Oct 2016 11:17:36 -0000 ------=_Part_1257596_630114099.1476872498891 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Cedric,=20 > De: "C=C3=A9dric Champeau" > =C3=80: dev@groovy.apache.org > Envoy=C3=A9: 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" 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 sl= ightly > different semantics would help our users/language. That said, the static > compiler can do better, doing escape analysis, and using "real" lambdas w= hen > the target bytecode is 8, as an optimization. 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.=20 The choice seems to be, the semantics of 'this' in a lambda in Groovy can b= e either the same as Java so you can copy/paste a Java code and it will wor= k as is in Groovy or the same semantics as in a Groovy closure so as you sa= id you will not have to explain why in Groovy { -> this } and () -> this do= not return the same value.=20 I have no opinion about that, i let you guys decide :)=20 That said, the lambda metafactory takes a desugared lambda as argument (a p= lain old static method, apart in corner cases), so choosing the semantics o= f the lambda in Groovy is orthogonal to the choice of using the lambda meta= factory or not.=20 R=C3=A9mi=20 ------=_Part_1257596_630114099.1476872498891 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi Cedric,


De: "C=C3=A9= dric Champeau" <cedric.champeau@gmail.com>
=C3=80: dev@groo= vy.apache.org
Envoy=C3=A9: Mercredi 19 Octobre 2016 09:09:51
<= b>Objet: Re: Lambda expression for Groovy 3
First of all, great work, Daniel ! I'm con= fident that making the "lambdas" be "closures" in Groovy is enough. I state= d 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 hel= p our users/language. That said, the static compiler can do better, doing e= scape analysis, and using "real" lambdas when the target bytecode is 8, as = an optimization.

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 Jav= a.
The choice seems to be, the semantics= of 'this' in a lambda in Groovy can be either the same as Java so you can = copy/paste a Java code and it will work as is in Groovy or the same semanti= cs as in a Groovy closure so as you said you will not have to explain why i= n Groovy { -> this } and () -> this do not return the same value.

I have = no opinion about that, i let you guys decide :)

That said, the lambda metafacto= ry takes a desugared lambda as argument (a plain old static method, apart i= n corner cases), so choosing the semantics of the lambda in Groovy is ortho= gonal to the choice of using the lambda metafactory or not.

R=C3=A9mi

------=_Part_1257596_630114099.1476872498891--