Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88567 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58705 invoked from network); 29 Sep 2015 21:56:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Sep 2015 21:56:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.49 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.213.49 mail-vk0-f49.google.com Received: from [209.85.213.49] ([209.85.213.49:35007] helo=mail-vk0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/61-46083-FE80B065 for ; Tue, 29 Sep 2015 17:55:59 -0400 Received: by vkao3 with SMTP id o3so13937159vka.2 for ; Tue, 29 Sep 2015 14:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=51b+KqytrAyqqvM/YcyvvwWnTkThEtLD7k7izqwd+C0=; b=FWeeMvTm997pyjw5qAvln9GcXR7CNrvxkWwwUSn8sGCJAnrpFLJJlCz+RUHlWJlzTq yOly8ME3Tz+aZFiBA/+BSvaoZg5RMoYXlPOIW8q5XXbH/PwVr6/9C3ISkf1xyP3LfsGc x6ATvG9hQ4ceM9JZubTvDyT3a/blSSQAluMn0VYqm17/yPPQN9TzT+f+M9H1A+0B/xt2 nlCn39Pa/fXDNUYYK2DBjdTqqJO7rCRDm+4C2xHDWnlX9hls5eIVKbr5JpltzBh1auQd 69MMnNa+nGeBc6C3gAJLPQTdzIy0KjAQd5O3700UDQ3IcmpfYt+xyCoTHBWLMrnx1pW+ kxLA== MIME-Version: 1.0 X-Received: by 10.31.158.213 with SMTP id h204mr264333vke.48.1443563756502; Tue, 29 Sep 2015 14:55:56 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.31.41.205 with HTTP; Tue, 29 Sep 2015 14:55:56 -0700 (PDT) In-Reply-To: References: Date: Tue, 29 Sep 2015 15:55:56 -0600 X-Google-Sender-Auth: cJC7AStpEyr5gtA9573ENtg5lhs Message-ID: To: =?UTF-8?Q?Pavel_Kou=C5=99il?= Cc: internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Arrow function expressions in PHP From: levim@php.net (Levi Morrison) On Tue, Sep 29, 2015 at 12:23 AM, Pavel Kou=C5=99il wr= ote: > On Tue, Sep 29, 2015 at 12:52 AM, Levi Morrison wrote: >> >> I do not think it is feasible to make the parser do backtracking or >> anything of that sort. How do others feel? >> >>> PS: the [fn($x) =3D> $x * 2] seems ambigous, from reader's POV; key of >>> the item is result of fn($x) and value is $x * 2? Also, it would be a >>> huge BC break with not allowing you to name functions fn(), wouldn't >>> it? >> >> This is not a huge backwards compatibility break, no. It is a small >> break. This is one reason `fn` is not necessarily what I will be >> proposing and want to hear more feedback. Note that the `function` >> version wouldn't be possible to be confused *at all*: >> >> // function($x) isn't allowed for function name >> // so this is very unambiguous >> [function($x) =3D> $x * 2]; >> >> Also note that using closures in array literals is not really that commo= n. > > When you choose the function($x) ~> $x * 2 (or with =3D=3D> or =3D> > operator), you end up saving around 5 or 6 characters from the "long > declaration", ending up with "not-so-short closures" instead. You save > a little bit more if you have the implicit "use", but that's one thing > people are torn about, by looking at the discussion about the RFC, but > I think it's too long, for "short closures". Reading over the list I don't think people "are torn about" it. There are some detractors, sure, but there seem to be more detractors about symbol choice (~) and lack of type declarations. > Would making the parser do some backtracking be really that bad - > especially since the option would end up with the IMHO most convenient > option for actual users of the feature? I disagree that `(int $x) =3D> $x * 2` is vastly better than `fn (int $x) =3D> $x * 2`. It *might* be better but so much better we should introduce backtracking into it? In my opinion that is very clear: no. Especially because this also makes it harder to write other tools for PHP.