Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99473 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19886 invoked from network); 10 Jun 2017 08:05:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jun 2017 08:05:54 -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:42784] helo=v-smtpout1.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/B3-01593-068AB395 for ; Sat, 10 Jun 2017 04:05:53 -0400 Received: from [192.168.7.8] ([195.198.188.252]) by cmsmtp with SMTP id JbP3dmyKHPPY2JbP3dojNt; Sat, 10 Jun 2017 10:05:49 +0200 To: Sara Golemon Cc: Rowan Collins , PHP internals References: <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> <4FBDE643-1EBC-485A-A39F-7E28C5D4807A@koalephant.com> <034f3ebf-95b8-a7cf-1279-77c7cf0424d7@gmail.com> <46143e7c-ef75-7c05-eaa9-98c8f3b405f1@telia.com> Message-ID: Date: Sat, 10 Jun 2017 10:05:43 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: sv X-CMAE-Envelope: MS4wfFOfF0s6YVQWJhOrE5ihpEhG9Wu6I/jcjrP6qNzM/vwOZXPXzMy4AzgU+lFGFul0veOJh2xr8uv4XSVzEUAvHzdFJjHQOZOmRiJkx69JY7yrMk9YKnvs UZT+DFZaVSF4hbt0fOqeXDQsDoKTKSnDiHmGqeRdeACj+84xOtm0T4JbfccBduVRzhEnpTW6KCY3hE5aR8S9rDPaQzrHO508v/jEh6ms4D3llPri2PKwr6cb rMyBqVf76THTQE5SRnBg7g== 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-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