From dev-return-4163-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Thu Feb 1 12:50:46 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 58C4F180652 for ; Thu, 1 Feb 2018 12:50:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 488F4160C44; Thu, 1 Feb 2018 11:50:46 +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 6B15A160C26 for ; Thu, 1 Feb 2018 12:50:45 +0100 (CET) Received: (qmail 20006 invoked by uid 500); 1 Feb 2018 11:50:44 -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 19991 invoked by uid 99); 1 Feb 2018 11:50:43 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Feb 2018 11:50:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 694D219A775 for ; Thu, 1 Feb 2018 11:50:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.293 X-Spam-Level: * X-Spam-Status: No, score=1.293 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=selskabet-org.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 8LIXh9dy4z6C for ; Thu, 1 Feb 2018 11:50:40 +0000 (UTC) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id CCB095FC26 for ; Thu, 1 Feb 2018 11:50:38 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id j21so2450297wmh.1 for ; Thu, 01 Feb 2018 03:50:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=selskabet-org.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=V0OzWPfVGSDSQR9jjom1Io+FnKjkLNRHrQAfegm8gME=; b=b9QzM32L5m/SqInZu36+oZxV8T4Np3xx1Wh+SiyBy+rA8yLCoaOnGRnDlSQlMRr80J ezzIk3RWEfCl1vpwD9ru/cdhI809ZsqClq4+AbuzKb3/Ob1EsV6DmJNSB5vbLbjoc3tA Tl/9IF+UBv8bKJEINHqSjVI5UclfwRqD1U3v5I2SiGcFkGcIn2/IFT1zCSUB0v8IASgj Wrav3aJ/pxlLKHYAKQ/HOJ8TzQ3G1zpT60x6dqJbsfETKW1WOnk7vJcDBn+zRe2iES7g t+xzP3S+iRBYd6XPt3u9JGFw37oSg0DAzDcw5yWjuhmXK40iI7+Y9LqPPVo09tcA8fyi mSpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=V0OzWPfVGSDSQR9jjom1Io+FnKjkLNRHrQAfegm8gME=; b=cWgRh5JxSw1PTQIaHtr76UOaineRN/iEuYrvVk3JauWsf/IiDBiQ95eIOrcQpTnXF8 4SebKrbEaa9KS0VrXzqSpTv1uT+/W91PmYcMnlObzRYJDHplGDIz80ihkeWDSshqkZar HzXOi+6G/nNeqJm2eQwm5MjGTy3d4tfGF07oiXnclI+CoB6B8vkplDpygmEkl3oBLfMt L8wk5hZKwEMJiq2KHKvDBeKXLjk83I53WiemAL5Eu6jBKCL/HW37RSZMg9qIt46niCCS WSa/C52cWvtoVHCv0QyjX+biGv8S8svBPg+EYAs29Af3i86pnroOXI5vg/wYH8msGp0U J+vQ== X-Gm-Message-State: AKwxyterPbvv4BC3KQ8JNeBevAT9kqdXOb8GbZLXL9mexKtwfc8G2vmJ 2TVqLm63GO3BrbanGqwA6vkEJLHqSac= X-Google-Smtp-Source: AH8x22597Ma78TxKp2P8wuMDe30tG70H3oEMOXKUvTODUy1/WNCJrAk81i7IxdC10aYtIdhgYExcog== X-Received: by 10.80.217.202 with SMTP id x10mr55165506edj.118.1517485831224; Thu, 01 Feb 2018 03:50:31 -0800 (PST) Received: from erst-l11282.es.lan ([37.49.142.33]) by smtp.gmail.com with ESMTPSA id a10sm9194023edh.2.2018.02.01.03.50.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 03:50:30 -0800 (PST) From: =?utf-8?Q?Jesper_Steen_M=C3=B8ller?= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: About the callable native lambda Date: Thu, 1 Feb 2018 12:50:28 +0100 References: <1517271265157-0.post@n5.nabble.com> <31CD6EAD-A943-44FE-B768-46B85E705E00@selskabet.org> <1517365000987-0.post@n5.nabble.com> <825D0D94-5654-4E10-B764-D6FCEFF3E240@selskabet.org> <1df879e2-43b9-4a6d-290f-e3e913381526@arscreat.com> To: dev@groovy.apache.org In-Reply-To: <1df879e2-43b9-4a6d-290f-e3e913381526@arscreat.com> Message-Id: X-Mailer: Apple Mail (2.3273) > On 31 Jan 2018, at 23.01, MG wrote: >=20 > Hi Jesper, >=20 > seen from a Groovy user perspective your proposal seems to make sense = to me. > (I would at the same time hope you do not dent Daniel Sun's enthusiasm = too much, because as far as I can tell he is currently doing alot of the = heavy lifting in this project :-) ) >=20 Yes, he is - and the lambda work has come a long way - I'm testing some = scenarios, so i hope to lift a little, too! > How do you think what you propose fares with regards to "the principle = of least surprise" ? Are there any cases where this could lead to hard = to track bugs / unexpected behavior ? =46rom the top of my hat, that = would be my biggest concern... I see static and dynamic as different concerns: For dynamic invocation, = there could be some surprises, like example posted by 'avafanasiev' on = GitHub: class R implements Runnable { void run(){}} def m(Runnable r1, R r2, r3) { r1() r2() r3() } m(new R(), new R(), new R()) Currently, in the 'native-lambda' branch, r1() succeeds, whereas the = latter two fail to run/compile (depending on dynamic/static = compilation), as 'avafanasiev' commented on. I do find that confusing: = Dynamically, my opinion is that the three should work the same. For static compilation, r1() and r2() should work IMHO, and r3() should = be rejected. This shouldn't surprise anyone, I think. Also, surprise-wise,=20 class Q implements Runnable, Predicate { void run(){}; boolean = test(String s) { s } } def n(Runnable q1, Predicate q2, Q q2, q3) { r1() r2() r3() } m(new R(), new R(), new R()) > "...only as a fallback if obj.call doesn't exist" seems like the = safer choice in this regard. Default behavior could also be made = overridable by a class annotation (then it would become the programmer's = responsibility, to make sure least surprise is not violated). > Without that the question to me is: Would choosing "fallback if = obj.call doesn't exist" weaken the elegance of the whole concept too = much ? >=20 > mg >=20 >=20 > On 31.01.2018 10:00, Jesper Steen M=C3=B8ller wrote: >> Hi list >>=20 >> FYI: This turned into a discussion of the feature itself, on the = GitHub commit thread. Basically, I'm proposing changing what = "obj(params...)" means: >> - Non-SAM types: obj(params...) becomes obj.call(params...) >> - SAM types: obj(params...) becomes obj.(params...) - = perhaps only as a fallback if obj.call doesn't exist. >>=20 >> This should be completely independent of how the lambda object itself = was created. >>=20 >> I realize this is a potentially breaking change, but isn't it also a = nice one? >> Thoughts? >>=20 >> -Jesper >>=20 >>> On 31 Jan 2018, at 03.16, Daniel Sun = wrote: >>>=20 >>> Hi Jesper, >>>=20 >>> I think your suggestion is very nice and I've completed callable = native >>> lambda according to option 2 :-) >>>=20 >>> Here is the related commit: >>> = https://github.com/apache/groovy/commit/c24c0b7e6a67dcdf277207d4261cfa6f2b= 55031f >>>=20 >>> Cheers, >>> Daniel.Sun >>>=20 >>>=20 >>>=20 >>> -- >>> Sent from: = http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html >>=20 >=20