Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99541 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26957 invoked from network); 18 Jun 2017 18:49:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2017 18:49:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.192.173 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.192.173 mail-pf0-f173.google.com Received: from [209.85.192.173] ([209.85.192.173:33449] helo=mail-pf0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/72-13828-E1BC6495 for ; Sun, 18 Jun 2017 14:49:03 -0400 Received: by mail-pf0-f173.google.com with SMTP id 83so44218934pfr.0 for ; Sun, 18 Jun 2017 11:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=nA+iiSRdt+v10jhKPDFl44GTbGMGThWEkPwkHAY9kMI=; b=C1/s6MxNTQ2LBEH+ey7ItkaNChgdwq5+AZpGzDJsdS8+NpZzIyRsKbHnPk9odmWCV/ j421FNbCysnAGEscwUCR/wcDLxqN5NCrB/OezYRxjxSiplx3QmBNDl7Sna/cgKtJrbsA B3IUHimpczOqjszxA60pSiLM3RUE6FSXqHvFUSWcHvOLA50ibZcWMSJvNS3UQUZq4QDm ABeQ2BHNPdXgwJ5RvgnM+XmWu2iXdDwA7DN40NWQvPzbV57WW6NC+lubKZLsif37uF7I qkVVr7qa6/SE+hfktMVfMOEp9ieoSgff7OdqFt/YBM+BSmAKgPdVMpYUf94vELa3DSb9 EwSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=nA+iiSRdt+v10jhKPDFl44GTbGMGThWEkPwkHAY9kMI=; b=lp6Jb1EIOR23M1w3Ffol4LxnVOdBIuESU1UG1oz+9aoy+yO6Ow4uOIW9m/wyfKOMiR dWYGe00yvbOnik7dNBwxlOXD/pu3J2mR788njjNyV/QlHkVxXKCiz+phRQl/+zR7WEWt kfvEmLYOs9sjOICXiAIjcWZs+YzpQfH+UIIK3Mipod8mAcUUPXXZSKnFwk1Lvr+9qSry 0Zqf+rkJ0OX7zWgVuACuem/pY0kJbyHJP2GjUPu6nmyYUXf7BJRHY7cqSxLTkkuxgECU LJOaKIbWPBe9R1gQhYYKBlFGuDVbSSOTqtq3NIJPwh+90r24XRz6oQUiyR7aM/oKkwg7 j5AA== X-Gm-Message-State: AKS2vOxk3Vr/X3aDLbd5ZZ8Y0xJ3mhJT/TsQZbZzmsjY0Iy59WzaY6A4 5l26rOvfrUSnrKryekJ/HW1UDaGtQUwm X-Received: by 10.98.103.134 with SMTP id t6mr21310795pfj.83.1497811739250; Sun, 18 Jun 2017 11:48:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.151.167 with HTTP; Sun, 18 Jun 2017 11:48:58 -0700 (PDT) In-Reply-To: <3C763609-54FC-480B-AE95-94A1873226E0@me.com> 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> <5fe1eefe-1c4f-4c31-c975-ab6c768c977c@telia.com> <3C763609-54FC-480B-AE95-94A1873226E0@me.com> Date: Sun, 18 Jun 2017 20:48:58 +0200 Message-ID: To: Ilija Tovilo Cc: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= , Fleshgrinder , PHP internals Content-Type: multipart/alternative; boundary="001a1137111aa8af8f05524078bc" Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: rasmus@mindplay.dk (Rasmus Schultz) --001a1137111aa8af8f05524078bc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I understand it's not ambiguous to the parser if it's a keyword. I was referring to the visual ambiguity - the fn($x) part of the syntax is indistinguishable from a function-call. On Sun, Jun 18, 2017 at 8:42 PM, Ilija Tovilo wrote: > > I don't agree that the fn keyword solves the ambiguity problem - it loo= ks > > exactly like a function call. > > > Right. But it does solve the ambiguity if `fn` is a keyword which is what > the RFC suggests. > > > > On 18 Jun 2017, at 18:40, Rasmus Schultz wrote: > > > > I don't agree that the fn keyword solves the ambiguity problem - it loo= ks > > exactly like a function call. > > > > As for the backslash, my honest reaction is, ugh, please, no more > > backslashes - PHP (and every other language) uses backslashes for > escaping > > in strings, it already looks pretty awkward in namespaces, this won't > help. > > > > > > On Sun, Jun 18, 2017 at 12:58 PM, Ilija Tovilo > wrote: > > > >> The backslash has actually been one of the earlier options if I rememb= er > >> correctly. > >> I definitely prefer the `fn` keyword as it=E2=80=99s only one characte= r more but > >> adds a better visual hint to the arrow function. > >> > >> I=E2=80=99m also not sure why we=E2=80=99d choose a different arrow (`= =3D=3D>` or `~>`) when > >> the ambiguity is solved through either a the backslash or the `fn` > keyword. > >> > >> > >>> On 15 Jun 2017, at 17:00, Bj=C3=B6rn Larsson > >> wrote: > >>> > >>> Den 2017-06-15 kl. 15:34, skrev Fleshgrinder: > >>> > >>>> On 6/15/2017 3:29 PM, Bj=C3=B6rn 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=C3=B6rn > >>>>> > >>>> On Reddit someone proposed the following syntax: > >>>> > >>>> \() =3D> 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) =3D> $v * 2)->filter(\($v) =3D> $v % 3); > >>> 9. $someDict->map(\($v) =3D=3D> $v * 2)->filter(\($v) =3D=3D> $v % 3)= ; > >>> 10. $someDict->map(\($v) ~> $v * 2)->filter(\($v) ~> $v % 3); > >>> > >>> Interesting :) > >>> > >>> r//Bj=C3=B6rn > >>> > >>> -- > >>> PHP Internals - PHP Runtime Development Mailing List > >>> To unsubscribe, visit: http://www.php.net/unsub.php < > >> http://www.php.net/unsub.php> > >> > > --001a1137111aa8af8f05524078bc--