Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99542 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30495 invoked from network); 18 Jun 2017 19:45:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2017 19:45:09 -0000 Authentication-Results: pb1.pair.com header.from=ilija.tovilo@me.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ilija.tovilo@me.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain me.com designates 17.172.220.113 as permitted sender) X-PHP-List-Original-Sender: ilija.tovilo@me.com X-Host-Fingerprint: 17.172.220.113 st11p02im-asmtp001.me.com Received: from [17.172.220.113] ([17.172.220.113:36350] helo=st11p02im-asmtp001.me.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/E2-13828-248D6495 for ; Sun, 18 Jun 2017 15:45:07 -0400 Received: from process-dkim-sign-daemon.st11p02im-asmtp001.me.com by st11p02im-asmtp001.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) id <0ORR01B00BPFGC00@st11p02im-asmtp001.me.com> for internals@lists.php.net; Sun, 18 Jun 2017 19:45:04 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=04042017; t=1497815104; bh=j6B4trV8zBH7fescl2369kiBxC3esJ5HAHvwaZaJzQE=; h=From:Message-id:Content-type:MIME-version:Subject:Date:To; b=tYb5lki0yOsvJrPmOhuqbGeCkhuUIG+rE4JBoIzBD39rEBPSUmChYnaJRDXA7Mxw8 M4g/7epXSinoa3HeC7zisuWtCmo8w6RdkhfMn8OU5tCiZjNz2UZI+yAWi6YNw9hFB/ PpEJ/eru7HCfC6c5rnxaIsks6Mj9bP43fWyv5MKOmLdb5ZTxU5OVeF8qxN85aIZjvC 1OubEwM8k9foZx0SMfgrd4PEWtovUELGCCRFiep+ZQ8NmN52KgDzzkPk2oUSns8ltP p/eZ6y9FyQgHrAJmgj/nB9rz4I+MLslOA+tchpKVoe/MRCnQfiUMzRdxSpSGAkUf/u MHQhDkxv/P18w== Received: from icloud.com ([127.0.0.1]) by st11p02im-asmtp001.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) with ESMTPSA id <0ORR00H3HDIYO710@st11p02im-asmtp001.me.com>; Sun, 18 Jun 2017 19:45:01 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-18_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=15 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1701120000 definitions=main-1706180357 Message-ID: <9A3447BF-F982-4C5A-B55B-466036AF2E53@me.com> Content-type: multipart/alternative; boundary="Apple-Mail=_96D2F748-447F-4964-906B-9C1672331FE8" MIME-version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Date: Sun, 18 Jun 2017 21:44:58 +0200 In-reply-to: Cc: =?utf-8?Q?Bj=C3=B6rn_Larsson?= , Fleshgrinder , PHP internals To: Rasmus Schultz 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> X-Mailer: Apple Mail (2.3273) Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: ilija.tovilo@me.com (Ilija Tovilo) --Apple-Mail=_96D2F748-447F-4964-906B-9C1672331FE8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Sorry, I wasn=E2=80=99t aware of that. What do you think of the Ruby/Rust style syntax that Levi proposed a = while back? $someDict ->map(|$v| $v * 2) ->filter(|$v| $v % 3); This one has a few advantages: 1. It has syntax (a lot of) developers are already familiar with 2. It has no ambiguities and is fully backward compatible 3. It=E2=80=99s the shortest of all options available (two `|` = characters and one space) > On 18 Jun 2017, at 20:48, Rasmus Schultz wrote: >=20 > I understand it's not ambiguous to the parser if it's a keyword. >=20 > I was referring to the visual ambiguity - the fn($x) part of the = syntax is indistinguishable from a function-call. >=20 >=20 > 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 = looks > > exactly like a function call. >=20 >=20 > Right. But it does solve the ambiguity if `fn` is a keyword which is = what the RFC suggests. >=20 >=20 > > On 18 Jun 2017, at 18:40, Rasmus Schultz > wrote: > > > > 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 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 > > >> >=20 >=20 --Apple-Mail=_96D2F748-447F-4964-906B-9C1672331FE8--