Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99369 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14909 invoked from network); 5 Jun 2017 18:11:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2017 18:11:14 -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:57553] helo=v-smtpout2.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 66/53-27119-1CE95395 for ; Mon, 05 Jun 2017 14:11:14 -0400 Received: from [192.168.7.8] ([195.198.188.252]) by cmsmtp with SMTP id HwT7dbTZzpjp6HwT7dcE22; Mon, 05 Jun 2017 20:11:09 +0200 To: Rowan Collins References: <6357d97c-3f2e-4cf8-cb1f-cb7f7ccccf7c@telia.com> <7eaef49b-bf60-9aa1-e812-8430164e3178@garfieldtech.com> <3F920987-38CB-42DD-888D-824430C36F14@gmail.com> Cc: PHP internals Message-ID: <2f9e73c9-444a-11d0-459a-e261ea8a7080@telia.com> Date: Mon, 5 Jun 2017 20:11:12 +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: <3F920987-38CB-42DD-888D-824430C36F14@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: sv X-CMAE-Envelope: MS4wfEQApTBtGu9BkNgcsvWfcmcylFCrqtdXCmAIFQVj3hgGYOk6UMZS0g2llOr43B+KTZXMOXzCCNXHmIYI/B5HYc9K/pFHU7yKmxq73Wi70Krs4iDRlr9U WXU6vZLRGqvmmTKiN4rSNC/WtMXSTZV2yuJAx5Xs2lzcUtD+aMnn4WRdH3wNAhhwAs7qxpM36hc+JJieNUpxKPdRYhgzC97mkA32AD6DlPtkwyFt2aQr26/Z 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-05 kl. 19:55, skrev Rowan Collins: > On 5 June 2017 18:17:06 BST, Fleshgrinder wrote: >> Could someone explain me again what the problem with the simple >> fat-arrow and normal parenthesis is? Cannot find it anymore (too many >> messages in too many thread I guess). I would guess that it has to do >> with the arbitrary look-ahead that is required to check for the fat >> arrow before the lexer knows that this is a short closure and not some >> parenthesis that simply groups something. > I think it's not just a case of implementation problems, it's actually ambiguous with current syntax: > > $foo = array( ($x) => 42 ); > > Sure, those inner brackets are redundant, so it's not likely to break much actual code, but it's kind of weird to have this one case magically turn into a closure, when anything else you put in those brackets would just be used as the array key: > > $foo = array( f($x) => 42 ); > $foo = array( ($x+1) => 42 ); > $foo = array( (42) => $x ); > $foo = array( (X) => 42 ); > $foo = array( ($x) => 42 ); > $foo = array( ("$x") => 42 ); > > Even if we could teach the parser to understand it, I'd personally be against it for the difficulty of *humans* parsing it. I find shorthand closures hard enough to read anyway, especially when people suggest things like ($x) => ($y) => $x * $y * $z; > > Regards, > +1, think you nailed it here :) One of the reasons I prefer the ==> syntax. r//Björn