Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99539 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20313 invoked from network); 18 Jun 2017 16:40:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2017 16:40:55 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.192.176 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.192.176 mail-pf0-f176.google.com Received: from [209.85.192.176] ([209.85.192.176:34725] helo=mail-pf0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/A1-13828-41DA6495 for ; Sun, 18 Jun 2017 12:40:52 -0400 Received: by mail-pf0-f176.google.com with SMTP id s66so43455235pfs.1 for ; Sun, 18 Jun 2017 09:40:51 -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=ydFt24nqGwik6LCIkidDXvY/Ud2f4HgJGh90+TWM4mA=; b=BxJQGZVeig06Ex0zt8vZlgOqWGCRcgQOhrD7t8RbCIntX7iH9p9dk5HyMTnmrfmkg5 iekmeHx6f0hrUdGcJdKceZ6Sj18wmfcqm+R1JI9A8s1NrZOYiz04kvjINddb5Q+gBCVg iECxDpZJbv16xP8HFOTVeTxtPttIW2OTQshadQA5WPCdagmvcWnd5ELXgz6rpNb6N57U YN9V9aBAXqJIHqY9y0HSAZclOZOK1D/GSi+Pp47alKKAqrxUAgpScgFVFSEypFO3CGzS q4G1zCxemTZox+rW8rbR+t2xVMWWTyi4ZclmxpWTwN+Y/t+/Z/iX9N9c5OAvDs25Y2Tk LjVA== 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=ydFt24nqGwik6LCIkidDXvY/Ud2f4HgJGh90+TWM4mA=; b=o2Ewv+ic8bB8SF+soS9ndpVwWwYtzDRiHfuuLdI9PnNQJbENUvuf9j4mCkl4cIutKB eF2E2vO+9I4Mok51Mlcm/4xiYEAHjrFPC7jO3G/tpETjav2ZODhF3GnBZulU98CSC+Q2 TX+yw47S07oMWn855g7xdsG8X8dMzno+61kkJnpcO9i7RbujobPJP+A5cIa1zthHxSAF BstKoIXaiCBX7NZ2NXSu0KvGPY2AtvJoE75HJDFxwSxeaRGa2fVckPGhd6tu1QoZgMYM xQE3YY28i5H4OXuWsecr8gxLSc0DXYeFpNGU1F8+0sysnyM7iy+HMehqJ2gNLyZufV75 NQ0A== X-Gm-Message-State: AKS2vOxToIIv3R87CiG9E5NrzDdJtBy7nuvXTqLWtAeTJrathOJS2/oR FpPsCUAu9GiL3ZM/ujbmCTtoyUtMcXqi X-Received: by 10.99.101.135 with SMTP id z129mr21548719pgb.66.1497804049582; Sun, 18 Jun 2017 09:40:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.151.167 with HTTP; Sun, 18 Jun 2017 09:40:48 -0700 (PDT) In-Reply-To: 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> Date: Sun, 18 Jun 2017 18:40:48 +0200 Message-ID: To: Ilija Tovilo Cc: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= , Fleshgrinder , PHP internals Content-Type: multipart/alternative; boundary="94eb2c116f685192af05523eae95" Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: rasmus@mindplay.dk (Rasmus Schultz) --94eb2c116f685192af05523eae95 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I don't agree that the fn keyword solves the ambiguity problem - it looks 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 remember > correctly. > I definitely prefer the `fn` keyword as it=E2=80=99s only one character m= ore 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` keywor= d. > > > > 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. I= t > >> 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> > --94eb2c116f685192af05523eae95--