Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99427 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9809 invoked from network); 7 Jun 2017 13:37:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jun 2017 13:37:18 -0000 Authentication-Results: pb1.pair.com header.from=bjorn.x.larsson@telia.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=bjorn.x.larsson@telia.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain telia.com from 81.236.60.155 cause and error) X-PHP-List-Original-Sender: bjorn.x.larsson@telia.com X-Host-Fingerprint: 81.236.60.155 v-smtpout2.han.skanova.net Received: from [81.236.60.155] ([81.236.60.155:34517] helo=v-smtpout2.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/4B-27119-A8108395 for ; Wed, 07 Jun 2017 09:37:17 -0400 Received: from [192.168.7.8] ([195.198.188.252]) by cmsmtp with SMTP id Ib94di8sSpjp6Ib95dgb28; Wed, 07 Jun 2017 15:37:11 +0200 To: Stephen Reay Cc: Ryan Pallas , Fleshgrinder , PHP internals References: <6357d97c-3f2e-4cf8-cb1f-cb7f7ccccf7c@telia.com> <7eaef49b-bf60-9aa1-e812-8430164e3178@garfieldtech.com> <3F920987-38CB-42DD-888D-824430C36F14@gmail.com> <2f9e73c9-444a-11d0-459a-e261ea8a7080@telia.com> <4077c099-2247-c3c1-7dee-02a6b25f8586@fleshgrinder.com> <559b73f7-c40f-e593-f0e1-51b56210d7cb@telia.com> <2053A608-6B66-42FB-A6D7-7CC64E94DA6A@koalephant.com> Message-ID: Date: Wed, 7 Jun 2017 15:37:09 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <2053A608-6B66-42FB-A6D7-7CC64E94DA6A@koalephant.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: sv X-CMAE-Envelope: MS4wfAMilNhrMk8YoUiVcDwScRuodgb07f6iiXh5YLu8LeJVMIRcCNs7UzVcwRz0sDF1y5OwdgX/g9LPFbp2SBnW6lFpy0PB5joKm75GEF1KY0qAsHtgDlJC T0QtowkJMFIhsqZzQPaA5PTf+JVPiHbuCszXOJJviN/oSG51vtdfleAwqqy5zr7TDtyTgXSU2N4+QIKV6AgWMDn+jRwaBRYU07pzDqtR0YgQXnefAQGFyeRj e5OyJ1KOmW+MVnZ3kOBGjr/jtXVJaF3bMzAJqx2UT6awihUu3TUWaj74Sfs3j7+m Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: bjorn.x.larsson@telia.com (=?UTF-8?Q?Bj=c3=b6rn_Larsson?=) Den 2017-06-06 kl. 06:38, skrev Stephen Reay: >> On 6 Jun 2017, at 03:18, Björn Larsson wrote: >> >> Den 2017-06-05 kl. 21:23, skrev Ryan Pallas: >> >>> On Mon, Jun 5, 2017 at 1:09 PM, Fleshgrinder wrote: >>> >>>> On 6/5/2017 9:03 PM, Ryan Pallas wrote: >>>>> However, ($obj) -> $var is valid variable property syntax. >>>>> >>>> Gosh, we really have support for everything. :D That one is even very >>>> important for stuff like `(new A)->f()`. >>>> >>>> How about ~> which I at least cannot think of any place it is used at >>>> all. ~ in binary negation and the only place we use it (I checked the >>>> language parser this time to make sure). >>>> >>>> I really dislike the ==> idea. One of the main reasons here is to write >>>> less and it looks too much like => or even >= which I really don't like. >>>> >>>> ($a, $b) ==> $a >= $b >>>> >>>> ($a, $b) ~> $a >= $b >>>> >>>> >>> I can get behind using the tilde. Keeps it concise, but it's visually >>> different than existing syntax, making it easier to recognize (IMO). >>> >> I think ~>was a proposal in the short closure RFC. Personally I liked it, >> but could also live with ==>. I recall there was a discussion about how >> easy it was to use tilde on different keyboards / languages. So at that >> point the discussion was about either ~> or ==> for syntax. >> >> But back to Levi's list it looks like, at least to me that option 2 & 4 are >> off the table. Leaving option 3 & 1, maybe also option 5. >> >> Do you think this is a reasonable assumption? >> >> Also some other proposals has arisen, like using lamda instead of fn as >> a keyword and lastly the ~> one. >> >> r//Björn >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php > As someone who sees limited appeal in short closures (Ok, they may make for slightly simpler constructs that are slightly too complex for a regular “collect” type collection method), I see a *lot* of people spending a *lot* of time to save typing 8 characters (function). > > If this feature truly is about making it easier to read, then that should be your goal: make it easy to mentally parse, basically instantly. Given that even proponents of the approach are admitting the syntax can get quite hard to understand quickly, perhaps it’s time to accept that “more characters” !== “harder to read & understand” and importantly, “less characters” !== “easier to read & understand”. > > How long does it take someone to type function? A second, maybe two? How many times are other people going to read that, once it’s been written? > > > Or maybe I’ve got it all wrong, and the goal is literally to save 8 keystrokes. If that’s the case, please update the RFC accordingly, to make it clear what the motivations are > Well, one reason to use fn or even lambda was to signal that this is different then a regular function. When it comes to number of keystrokes I guess that some inspiration has been taken from other languages supporting arrow functions, like Javascript & HACK. I also recall from earlier discussions, that with less keystrokes it's easier to read when an arrow function is embedded / chained into another expression / statement / function call. r//Björn