Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98061 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55923 invoked from network); 31 Jan 2017 04:53:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jan 2017 04:53:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=php-lists@koalephant.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php-lists@koalephant.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain koalephant.com designates 206.123.115.54 as permitted sender) X-PHP-List-Original-Sender: php-lists@koalephant.com X-Host-Fingerprint: 206.123.115.54 mail1.25mail.st Received: from [206.123.115.54] ([206.123.115.54:44112] helo=mail1.25mail.st) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/CE-51557-95810985 for ; Mon, 30 Jan 2017 23:53:46 -0500 Received: from [10.0.1.63] (unknown [183.89.40.46]) by mail1.25mail.st (Postfix) with ESMTPSA id C28F660336; Tue, 31 Jan 2017 04:53:36 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) In-Reply-To: Date: Tue, 31 Jan 2017 11:53:32 +0700 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <3F428CA4-8211-44E6-9B60-62ADB47934B3@koalephant.com> References: To: Andrea Faulds X-Mailer: Apple Mail (2.3124) Subject: Re: [PHP-DEV] Re: [RFC][Discuss] Arrow Functions From: php-lists@koalephant.com (Stephen Reay) Hi Andrea, All, > On 31 Jan 2017, at 08:12, Andrea Faulds wrote: >=20 > Is it necessary to introduce a new keyword, fn? >=20 > I think you'd get a similar benefit from: >=20 > function($x) =3D> $arr[$x] >=20 > Likewise, is it necessary to restrict auto-capture to the =3D> syntax? = Couldn't we allow the following? >=20 > function ($x) { > return $arr[$x]; > } >=20 I agree that the `fn` keyword isn=E2=80=99t really necessary. I=E2=80=99ve= never quite understood how arrow functions with implied returns etc are = supposed to make for *more* readable code, but if they=E2=80=99re 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 =E2=80=98fun=E2= =80=99 I kind of like that with PHP you only inherit the variables you = explicitly `use()` in closures. Cheers Stephen