Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99531 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44665 invoked from network); 15 Jun 2017 15:01:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jun 2017 15:01:00 -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:44820] helo=v-smtpout2.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B7/32-30621-B21A2495 for ; Thu, 15 Jun 2017 11:00:59 -0400 Received: from [192.168.8.16] ([94.254.95.82]) by cmsmtp with SMTP id LWGWd85fmpjp6LWGWdwgI8; Thu, 15 Jun 2017 17:00:56 +0200 To: Fleshgrinder Cc: 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: <5fe1eefe-1c4f-4c31-c975-ab6c768c977c@telia.com> Date: Thu, 15 Jun 2017 17:00:55 +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: MS4wfLw2t6kTZToXz+5OQGQZKsjS8b0QWhGDsOqaSJtPwzGWEIS5bRXTDMRe4HFfm8vjkerkERNzABdmgrXdD+/o4ZGfupi+dOdVkQHCNqkk5/ht8vpX8d+V eVO/b2sDsfyoQAvMT92xA2ksgVSyaMguQoWA7uxr+x1nmiC8rhIfxKOeTWu5mOR1yAcVFKNmqHaJqtRoRwL4cGSAiZrfQS8qKfc= 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-15 kl. 15:34, skrev Fleshgrinder: > On 6/15/2017 3:29 PM, Björn Larsson wrote: >> 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 >> > On Reddit someone proposed the following syntax: > > \() => echo 'Hello, World' > > It is used by Haskell if I remember correctly and should not be > ambiguous since `(` is not allowed in names of classes or functions. It > actually aligns well with functions that are called with a > fully-qualified name (e.g. `\printf('')`). > > Not sure if it would still require hacks though. > So applying that one on Sara's example becomes with some options for the arrow: 8. $someDict->map(\($v) => $v * 2)->filter(\($v) => $v % 3); 9. $someDict->map(\($v) ==> $v * 2)->filter(\($v) ==> $v % 3); 10. $someDict->map(\($v) ~> $v * 2)->filter(\($v) ~> $v % 3); Interesting :) r//Björn