Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98062 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60404 invoked from network); 31 Jan 2017 05:44:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jan 2017 05:44:37 -0000 Authentication-Results: pb1.pair.com header.from=dev@mabe.berlin; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dev@mabe.berlin; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mabe.berlin from 80.237.132.167 cause and error) X-PHP-List-Original-Sender: dev@mabe.berlin X-Host-Fingerprint: 80.237.132.167 wp160.webpack.hosteurope.de Received: from [80.237.132.167] ([80.237.132.167:56700] helo=wp160.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/4F-51557-C3420985 for ; Tue, 31 Jan 2017 00:44:36 -0500 Received: from dslb-094-223-149-213.094.223.pools.vodafone-ip.de ([94.223.149.213] helo=[192.168.178.53]); authenticated by wp160.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1cYREv-0002TI-HF; Tue, 31 Jan 2017 06:44:25 +0100 To: internals@lists.php.net References: <3F428CA4-8211-44E6-9B60-62ADB47934B3@koalephant.com> Message-ID: <5bfde844-beee-0f15-1f92-f77607f70ae6@mabe.berlin> Date: Tue, 31 Jan 2017 06:44:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <3F428CA4-8211-44E6-9B60-62ADB47934B3@koalephant.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-bounce-key: webpack.hosteurope.de;dev@mabe.berlin;1485841475;d7eff0f7; X-HE-SMSGID: 1cYREv-0002TI-HF Subject: Re: [PHP-DEV] Re: [RFC][Discuss] Arrow Functions From: dev@mabe.berlin (Marc Bennewitz) Am 31.01.2017 um 05:53 schrieb Stephen Reay: > Hi Andrea, All, > >> On 31 Jan 2017, at 08:12, Andrea Faulds wrote: >> >> Is it necessary to introduce a new keyword, fn? >> >> I think you'd get a similar benefit from: >> >> function($x) => $arr[$x] >> >> Likewise, is it necessary to restrict auto-capture to the => syntax? Couldn't we allow the following? >> >> function ($x) { >> return $arr[$x]; >> } >> > > I agree that the `fn` keyword isn’t really necessary. I’ve never quite understood how arrow functions with implied returns etc are supposed to make for *more* readable code, but if they’re going to be part of the language please at least keep some consistency with regular closures. > > In the case that regular closures got auto-capture, would a `use($foo, $bar, $baz)` segment on a closure still be honoured (i.e. disable auto-capture), and would it have any impact (positive or negative) on performance/memory usage? After several years of JS closure ‘fun’ I kind of like that with PHP you only inherit the variables you explicitly `use()` in closures. I like the general idea, too. But with similar feelings for: - Introducing a second keyword for closures is confusing - and mor confusing if they are basically the same words - Also I like the "use" keyword you have to define your variables -> Would it be helpful to allow "function () use (*) {}" to inline all available variables? - Or based on Rowans idea to stretching the brackets but using the function keyword: function($x => $arr[$x]) Thanks Marc > > Cheers > > Stephen >