Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99472 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99557 invoked from network); 9 Jun 2017 23:58:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jun 2017 23:58:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.52 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.214.52 mail-it0-f52.google.com Received: from [209.85.214.52] ([209.85.214.52:35733] helo=mail-it0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9F/E2-01593-9063B395 for ; Fri, 09 Jun 2017 19:58:01 -0400 Received: by mail-it0-f52.google.com with SMTP id m62so4610153itc.0 for ; Fri, 09 Jun 2017 16:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=+Y7C/ITl9YFhDCEEaIc95p0vKFBoym6UxF+APA4eBcQ=; b=f4CIOOMePvIOtBskb7iVIOk+b3q/5jmHF8f52Lt08dKG9WUy7k2ejaQV0GfCrz/d5m JC5CfSHcSNEw/zh9ty8KSuJKV2Z1qKpZ22SeHaWoTO7RcQ0vZ7WD1hAOPWNoy14TxdZm qWiZpwDOXTDxP556MBJd3Mz+kquy4r8iyK6nh55+18FLik8YQDfb0ZG8F9LnruRBK/Gt PpM2t1phV9W11VWORfLoZDZcBfSPOkAdD21r+sSRVrt5GJU5+Rgk4SHCTyFME/O9vVLC JNOtAPIK9QqdXHiMlOBgyO9fSKVVe1p7oqpoYPEajAAtdTNUdOGW/MEBZx3lk+yybhwM 5Vpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=+Y7C/ITl9YFhDCEEaIc95p0vKFBoym6UxF+APA4eBcQ=; b=E97Lm/YTLDGpL58ksKWxizzGI6cSyYfN5V/pQS0fCZQt04nb6Vdy/mkHvn3D+boK3V RwG8lzG2d32Y1PlJxCwfQVMKRJieM8887hArLI4PBdlTi3vuVRm6Hx5wHCCyYIJbtyO9 vxke6z+uWBcLrffH4aZlrIqHgO3JfEioQ9Qm0a2f9T+m1SzpGT793E9gB0kSPnkXm1PL xYS397oG3HjhzigVFo2oorKCwrZeWkfbtBzNcW+CEj+SsHz+UJlf607uvWm2KUyODwiH BsA3YEwj6L1vPSTbwB+2VR/RpDk2tNKw7q+xuABwV/B6txukr7pMDdZG+Xn9p4vTrOxe goVA== X-Gm-Message-State: AODbwcAGUjwnd33BrIVXPzARAOIbzWoRHUFewIK6WbWVzum6+j8Tc70W b0EnO8NlNeqd9tW41q13ypGnxXANkg== X-Received: by 10.107.151.139 with SMTP id z133mr8739959iod.98.1497052678681; Fri, 09 Jun 2017 16:57:58 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.107.12.159 with HTTP; Fri, 9 Jun 2017 16:57:57 -0700 (PDT) In-Reply-To: <1E0ECC7E-B960-46EB-9953-538DF874EA9B@gmail.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> <1E0ECC7E-B960-46EB-9953-538DF874EA9B@gmail.com> Date: Fri, 9 Jun 2017 17:57:57 -0600 X-Google-Sender-Auth: em9EuBGAdHpIJ5t0QSTBhf_jgdE Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: levim@php.net (Levi Morrison) On Fri, Jun 9, 2017 at 4:43 PM, Rowan Collins wro= te: > On 9 June 2017 21:00:48 BST, Niklas Keller wrote: >>2017-06-09 15:44 GMT+02:00 Sara Golemon : >> >>> On Fri, Jun 9, 2017 at 7:23 AM, Bj=C3=B6rn Larsson >> >>> wrote: >>> > If I take the liberty in using the example above on our option >>list: >>> > 1. $someDict->map(fn($v) =3D> $v * 2)->filter(fn($v) =3D> $v % 3); >>> > 2. $someDict->map(function($v) =3D> $v * 2)->filter(function($v) =3D> >>$v % >>> 3); >>> > 3. $someDict->map($v =3D=3D> $v * 2)->filter($v =3D=3D> $v % 3); >>> > 4. $someDict->map(($v) =3D> $v * 2)->filter(($v) =3D> $v % 3); >>// >>> > Ambiguous >>> > 5. $someDict->map([]($v) =3D> $v * 2)->filter([]($v) =3D> $v % 3); >>> > >>> > Old proposals: >>> > 6. $someDict->map($v ~> $v * 2)->filter($v ~> $v % 3); >>> > 7. $someDict->map(lambda($v) =3D> $v * 2)->filter(lambda($v) =3D> $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 =3D=3D>, but I think that shows a little bit of why the >>HackLang >>> team decided the messy lexer was worth the clearer syntax. >> >> >>Another possible syntax (dunno whether this has already been suggested >>on-list): >> >>$function =3D { $x =3D> 2 * $x }; >>$function =3D { ($x) =3D> 2 * $x }; >>$function =3D | $x =3D> 2 * $x |; >>$function =3D | ($x) =3D> 2 * $x |; >> >>Nikita and Levi prefer it with parenthesis, I prefer it without, >>because I >>think it's unnecessary clutter. > > I already suggested the brace version, and Levi said it would conflict in= the parser: https://externals.io/thread/911#email-15331 I don't know enoug= h about parsing to comment on what workarounds would be possible. It ends up not conflicting; when at top level you can keep existing behavior and otherwise make it a closure. Given that creating a closure without assigning it to variable or passing it to a function is useless this is fine.