Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98057 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41373 invoked from network); 30 Jan 2017 23:05:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jan 2017 23:05:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wm0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:38735] helo=mail-wm0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/1D-51557-5B6CF885 for ; Mon, 30 Jan 2017 18:05:25 -0500 Received: by mail-wm0-f54.google.com with SMTP id r141so55382441wmg.1 for ; Mon, 30 Jan 2017 15:05:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=qIVKmHf0Xfgv/d2ZoDIkxF4HoUVwJlN3gmKWwzRzLsU=; b=IlUOXw70uVkmf+kaHv0KuldqUAh6Tp+cn5iKODe61Kjkg/C9qzDcmeMtcK66eZxAHx 4FI7Pv+54XKviUvRrgZUBdVqDu91dwWuWc222iFVwq1o63g1pc3d4Xvq2yvgnARbLYjq qjR46o12Od+3elf9AlqIulxUoZeBOdoVfFv5XXuSWmw2U/9lqM0tg6ZceYBZZk/V2VU1 vkIT9mbyglEPol/o27aCkBm2X/VRYr26z2hhw8czFS5gRk1OapYdV3gspIMBRer85GB5 Wkq3YcGzRCSkCZ+tlt2F9DPPhaodXWoU6g6LcI02yTN+J/hDPgncInSsJCpSLXJwccRx GBlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=qIVKmHf0Xfgv/d2ZoDIkxF4HoUVwJlN3gmKWwzRzLsU=; b=HlDoJdACcj1BDYVQl9wUoWTX77G3lxXg9BP+O7QK8AG1TDZ2yNoYdejM2Xnn0adwau ctBHWFpjJg8B+LqHlsQH970aMWypsyZqgO2sILz8u2Y0Mel1DMtEIaCmTukkmC3Uk94V ve54jYhNFeXITGLhisRwpF8b4mz3jfRAbbngI6ohu2MEDeLJGQ361nKmYndN0QFXStxM n9hjOlB4HgRDVfW0T4RGiUc6hyUtJHxe+F6iDUNa44VgsK+ILRYLc57WiRCKcv9o+qAz ykVEHHabaUPPvkyHCk7Mlg2f/uzTvHMO4MrAf9FGBm0eMFrw7kh56pdFl43S/AJY/iII NCZg== X-Gm-Message-State: AIkVDXKub3dJlZSQ6jO4D33cnIfN5KSTjP2zhSfmaaSF0V19tH2jspY9TxC4oP3ut1wDrQ== X-Received: by 10.28.132.9 with SMTP id g9mr17571651wmd.28.1485817522110; Mon, 30 Jan 2017 15:05:22 -0800 (PST) Received: from ?IPv6:2a00:23c4:4bd2:6e00:f1f2:1ad0:32bc:f645? ([2a00:23c4:4bd2:6e00:f1f2:1ad0:32bc:f645]) by smtp.googlemail.com with ESMTPSA id v102sm25033649wrb.11.2017.01.30.15.05.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2017 15:05:21 -0800 (PST) To: internals@lists.php.net References: Message-ID: <5cfd2ff9-d4b1-e1cc-e4a3-c3b26b9b7fba@gmail.com> Date: Mon, 30 Jan 2017 23:05:19 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Discuss] Arrow Functions From: rowan.collins@gmail.com (Rowan Collins) On 30/01/2017 17:55, Levi Morrison wrote: > Bob Weinand and I are happy to announce that the [Arrow Functions][1] > RFC is moving into the public discussion phase. We have been > collaborating on this RFC for many months now and finally have a > proposal we are happy to discuss in the open. > > [1]: https://wiki.php.net/rfc/arrow_functions Firstly, I like this proposal a lot more than the previous, so thank you for working on this based on previous discussion. In particular, I'm glad to see it focused on single expressions with implicit return, as I think that's where it has most value. A few comments: > ThisRFC does support type declarations for parameters and return types. An example of the syntax for this would be good, particularly how the return type fits the syntax (which may conflict with my suggestion below). > The implementation currently supports static closures, for example |static fn($x) => static::get($x)|. I was initially confused by this paragraph, because I was unaware that static closures existed. I'm still not entirely sure *why* they exist, but for anyone else wondering, here's what they currently look like: http://php.net/manual/en/functions.anonymous.php#functions.anonymous-functions.static Finally, my personal preference is still for a syntax that encloses the whole definition somehow, and since we need the fn keyword anyway, I wonder about stretching the brackets around the whole definition, e.g. fn($x => $x * 2). Personally, I find this: ->reduce(fn($tmp, $v => $tmp + $v), 0) easier to mentally parse than this: ->reduce(fn($tmp, $v) => $tmp + $v, 0) because you only have to match brackets to see where the ", 0" belongs. I also think it would make combining closures clearer if they were nested rather than associative (I guess those used to reading Haskell will probably disagree with me): $complement = fn($f) => fn(... $args) => !$f(... $args) vs $complement = fn($f => fn(... $args => !$f(... $args))) Regards, -- Rowan Collins [IMSoP]