Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98159 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16652 invoked from network); 4 Feb 2017 00:07:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2017 00:07:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=aaron@trowski.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=aaron@trowski.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain trowski.com designates 199.38.81.6 as permitted sender) X-PHP-List-Original-Sender: aaron@trowski.com X-Host-Fingerprint: 199.38.81.6 mercury.negativeion.net Received: from [199.38.81.6] ([199.38.81.6:55607] helo=mercury.negativeion.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 96/EB-38491-45B15985 for ; Fri, 03 Feb 2017 19:07:48 -0500 Received: from localhost (localhost [127.0.0.1]) by mercury.negativeion.net (Postfix) with ESMTP id 58694475848E; Fri, 3 Feb 2017 19:07:45 -0500 (EST) X-Virus-Scanned: amavisd-new at negativeion.net Received: from mercury.negativeion.net ([127.0.0.1]) by localhost (mercury.negativeion.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mNLN14WaksJM; Fri, 3 Feb 2017 19:07:44 -0500 (EST) Received: from [10.0.1.3] (unknown [192.119.134.23]) by mercury.negativeion.net (Postfix) with ESMTPSA id 8098E4758473; Fri, 3 Feb 2017 19:07:44 -0500 (EST) Content-Type: multipart/alternative; boundary="Apple-Mail=_EA9440D3-15A8-4811-8016-F594F26EBAA9" Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) In-Reply-To: Date: Fri, 3 Feb 2017 18:07:43 -0600 Cc: Levi Morrison , tendoaki@gmail.com Message-ID: <9B585DD7-D90B-4BCD-8432-7FEA0A17EA6C@trowski.com> References: To: internals X-Mailer: Apple Mail (2.3124) Subject: Re: [PHP-DEV] [RFC][Discuss] Arrow Functions From: aaron@trowski.com (Aaron Piotrowski) --Apple-Mail=_EA9440D3-15A8-4811-8016-F594F26EBAA9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Feb 3, 2017, at 11:53 AM, Levi Morrison wrote: >=20 > One more thing: I'd like to re-emphasize that the syntax that > JavaScript uses and the one that HHVM/Hack uses are ambiguous in the > current class of our grammar. The following will not work unless we > move to a more powerful grammar and parser class: >=20 > (params) =3D> expr > (params) =3D=3D> expr >=20 > This is why an un-ambiguous prefix is necessary: the prefix breaks the > ambiguities. The syntax I have suggested in the RFC and the one I > suggested just now are not ambiguous because distinct prefixes: >=20 > fn(params) =3D> expr > |params| =3D> expr >=20 > I look forward to more discussion! >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php = I personally prefer the `|params| =3D> expr` syntax. I like the visual separation the syntax provides between auto-capturing, = short closures and regular closures. It gives the impression that it = should behave differently, rather than just being a shorter way of = declaring a closure. Below are a couple of real-world single line closures using the proposed = syntax: [1] Loop::defer(|| =3D> ($this->when)($exception, $value)); [2] $this->watcher =3D Loop::delay($time, || =3D> = $this->resolve($value)); IMHO, the reduced boilerplate required makes it easier to discern what = is happening. Regards, Aaron Piotrowski [1] https://github.com/amphp/amp/blob/master/lib/Coroutine.php#L45-L47 [2] https://github.com/amphp/amp/blob/master/lib/Pause.php#L21-L23= --Apple-Mail=_EA9440D3-15A8-4811-8016-F594F26EBAA9--