Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99469 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87192 invoked from network); 9 Jun 2017 20:00:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jun 2017 20:00:54 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.220 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.220 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.220] ([81.169.146.220:20767] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/91-01593-47EFA395 for ; Fri, 09 Jun 2017 16:00:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1497038450; l=4410; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=CrIKEZZYrjJXWFGaEg0XoG6zcEIB6yPJPdQ31kL7TQM=; b=ARll9lZ6MnXjaUGQrvjx9YUabX+QO/KPH+5DBxJBRKflgjwwGf50xtvaJp9m+DZeBE 8yrefflZtGUjz/xaY6BO2fGUKtbWd62hIWhPJQWq1sPOtOAkgS0TD5NlmQ3tSfswgYgf nI1XyLJ7GGf/QDn/5dl3cEqxXWtIbNRgZd6UU= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLDup6E67mzuoNHBqX93Q== X-RZG-CLASS-ID: mo00 Received: by mail-oi0-f45.google.com with SMTP id s3so34825030oia.0 for ; Fri, 09 Jun 2017 13:00:49 -0700 (PDT) X-Gm-Message-State: AODbwcCV0Zn2XxKim7tp2GqrupBwGi83oQUEGTux5iE/s0QVPMoZPpav 7YTExWtb9GpMV+VhHG1qIZ2rSGUMlQ== X-Received: by 10.202.206.23 with SMTP id e23mr22639433oig.168.1497038448957; Fri, 09 Jun 2017 13:00:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.176.133 with HTTP; Fri, 9 Jun 2017 13:00:48 -0700 (PDT) In-Reply-To: References: <7eaef49b-bf60-9aa1-e812-8430164e3178@garfieldtech.com> <3F920987-38CB-42DD-888D-824430C36F14@gmail.com> <2f9e73c9-444a-11d0-459a-e261ea8a7080@telia.com> <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> Date: Fri, 9 Jun 2017 22:00:48 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Sara Golemon Cc: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= , Rowan Collins , PHP internals Content-Type: multipart/alternative; boundary="001a113ac724f7247205518c6cbd" Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: me@kelunik.com (Niklas Keller) --001a113ac724f7247205518c6cbd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 HackLan= g > 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. A reason to use | ... | instead of { ... } would be to allow future object literals. Regards, Niklas --001a113ac724f7247205518c6cbd--