Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88621 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51454 invoked from network); 1 Oct 2015 19:56:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Oct 2015 19:56:00 -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.154 cause and error) X-PHP-List-Original-Sender: bjorn.x.larsson@telia.com X-Host-Fingerprint: 81.236.60.154 v-smtpout1.han.skanova.net Received: from [81.236.60.154] ([81.236.60.154:51931] helo=v-smtpout1.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 82/94-26330-DCF8D065 for ; Thu, 01 Oct 2015 15:55:58 -0400 Received: from [192.168.7.4] ([195.198.188.252]) by cmsmtp with SMTP id hjxJZrPnd9HQVhjxJZ1Sjq; Thu, 01 Oct 2015 21:55:54 +0200 To: Bishop Bettini , Anthony Ferrara References: <5606D0EB.3060106@gmail.com> <560D0F94.8060009@gmail.com> <560D282F.6060202@gmail.com> Cc: PHP internals Message-ID: <560D8FCB.5080808@telia.com> Date: Thu, 1 Oct 2015 21:55:55 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfPcyxCb52KmPXuRen3NB8FetJkIrC9ysNdqWumtO/1da5qxlaug8V6nDv2wd1P4G2VlX5D/rhogB/t0UFeu0ad3oZQEqS9GMpEZXA9I5Oyarx0rgBN0ssVPaFoxZDvaYG6InciVvKqT+17ziILYGicjbDbgzYqvsZmZTYqJcaTZd7WSRaT3tLWoDazFeGv9E5JITTBU2edhMRgE2OBNGlOtWhR11FMSDpkVY9A8SvZke47PVT4cWH73RMwUp1WA/ZQ== Subject: Re: [PHP-DEV] Arrow function expressions in PHP From: bjorn.x.larsson@telia.com (=?UTF-8?Q?Bj=c3=b6rn_Larsson?=) Den 2015-10-01 kl. 19:12, skrev Bishop Bettini: > On Thu, Oct 1, 2015 at 12:28 PM, Anthony Ferrara > wrote: > >> Nikita and all, >> >>> I don't think there was a dozen of different ideas, I could only find >> those >>> about `lambda(arg-list; use-list; expression)` and variations of it with >>> different keywords and different return-type syntax. >>> I do understand that this is quite subjective, but neither this syntax >> nor >>> `fn(arg-list; use-list) expression` look obvious and easily readable to >> me. >> >> The problem is that semicolons are non-obvious, especially in a >> context where commas are used (and traditionally used). >> >> Example, tell the difference quickly between >> >> fn($a, $b; $c) => $a + $b + $c; >> >> and >> >> fn($a; $b, $c) => $a + $b + $c. >> >> At a glance, they are identical. You have to actually look at each >> item to realize that there's a difference. At least with use() there's >> a syntactical separator there to draw your eye to the contextually >> relevant information. > True. But a developer can mitigate with judicious white-space: > > fn($a, $b ; $c) => $a+$b+$c > > Or we can figure out some other such symbol. Worse casing no white space, > brain storming: > > fn($a,$b:$c) => $a+$b+$c // not much better > fn($a,$b!$c) => $a+$b+$c // better, but looks like not > fn($a,$b&$c) => $a+$b+$c // lost in the noise, looks like bitwise > fn($a,$b%$c) => $a+$b+$c // perl jibberish, looks modulo > fn($a,$b--$c) => $a+$b+$c // multi-char, looks like decrement > fn($a,$b::$c) => $a+$b+$c // maybe, kinda confusing > > // my favorite > fn($a, $b @ $c) => $a + $b + $c; > Would it be: fn($a, $b @ $c, $d) => $a + $b + $c + $d; with several parameters? And if one could solve the parser problem it could be with typehint & a default value either: (int $a = 10, int $b @ $c, $d) => $a + $b + $c + $d; or (int $a = 10, int $b @ $c, $d) ==> $a + $b + $c + $d; or (int $a = 10, int $b @ $c, $d) ~> $a + $b + $c + $d; Regards //Björn