Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99528 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37294 invoked from network); 15 Jun 2017 13:29:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jun 2017 13:29:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=bjorn.x.larsson@telia.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=bjorn.x.larsson@telia.com; 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:51174] helo=v-smtpout2.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/11-30621-ACB82495 for ; Thu, 15 Jun 2017 09:29:48 -0400 Received: from [192.168.8.16] ([94.254.95.82]) by cmsmtp with SMTP id LUqFd7qz4pjp6LUqFdwXKK; Thu, 15 Jun 2017 15:29:44 +0200 To: Sara Golemon Cc: Rowan Collins , PHP internals References: <4077c099-2247-c3c1-7dee-02a6b25f8586@fleshgrinder.com> <559b73f7-c40f-e593-f0e1-51b56210d7cb@telia.com> <2053A608-6B66-42FB-A6D7-7CC64E94DA6A@koalephant.com> <4FBDE643-1EBC-485A-A39F-7E28C5D4807A@koalephant.com> <034f3ebf-95b8-a7cf-1279-77c7cf0424d7@gmail.com> <46143e7c-ef75-7c05-eaa9-98c8f3b405f1@telia.com> Message-ID: Date: Thu, 15 Jun 2017 15:29:42 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: sv X-CMAE-Envelope: MS4wfKWbP+V6Lvo/pDaTyGX/7CyzxTvrTM1CChVi/H4nrFQgxgWfaAQxYr6Gel0qBlZTxgtxgaZMVu1KpxTCjjhR7JkdIHj6S+9jUwHzdg2bGCVfBtfkJrrE 0ydx4421EJ1+DY6ikX8upaP4Vp1Tfwz9E5ONXBsojdGQgD6679KYu4Ij7/+IUaurlDqtEzVQySGMBWig2ymd86cTq7zdJWw5r7LSD/5g+p2WD8/hlxWyrRqW Cg3hmG+WPpgGOctTSWjJ2Q== 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-10 kl. 10:05, skrev Björn Larsson: > Den 2017-06-09 kl. 15:44, skrev Sara Golemon: >> On Fri, Jun 9, 2017 at 7:23 AM, Björn Larsson >> wrote: >>> If I take the liberty in using the example above on our option list: >>> 1. $someDict->map(fn($v) => $v * 2)->filter(fn($v) => $v % 3); >>> 2. $someDict->map(function($v) => $v * 2)->filter(function($v) => $v >>> % 3); >>> 3. $someDict->map($v ==> $v * 2)->filter($v ==> $v % 3); >>> 4. $someDict->map(($v) => $v * 2)->filter(($v) => $v % 3); // >>> Ambiguous >>> 5. $someDict->map([]($v) => $v * 2)->filter([]($v) => $v % 3); >>> >>> Old proposals: >>> 6. $someDict->map($v ~> $v * 2)->filter($v ~> $v % 3); >>> 7. $someDict->map(lambda($v) => $v * 2)->filter(lambda($v) => $v % 3); >>> >> Something else which really pops in these examples is the effect of >> not needing to use parentheses when embedding a single-arg short >> lambda. 3 and 6 in your list read cleaner to me (due to the lack of >> parenthesis clutter). Sadly ~> has the same hacky implementation >> issues as ==>, but I think that shows a little bit of why the HackLang >> team decided the messy lexer was worth the clearer syntax. >> > Yup, totally agree on that one. It improves redability and when you have > more parameters I find the parenthesis less disturbing like. > - $someDict->map(($v, $y) ==> $v * 2 + $y)->filter(($v, $y) ==> $v % 3 > - $y); > > Btw, do you think there is a way around the hacky implementation, given > that PHP now has a new and shining engine? > > r//Björn > Seems like the constraints on this feature makes it hard to fly, i.e. 1. Not a hackish implementation 2. Non ambiguous syntax 3. Easy to parse & use syntax for the human HackLang then prioritised 2 & 3 making the end-users happy, but had to sacrifise a clean implementation. Any clue if this was a one- time effort once it was done or something with a lot of drawbacks in terms of maintenance, performance, evolution etc? r//Björn