Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99574 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84722 invoked from network); 20 Jun 2017 14:52:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2017 14:52:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilija.tovilo@me.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ilija.tovilo@me.com; 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:26207] helo=st11p02im-asmtp001.me.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/E2-13828-79639495 for ; Tue, 20 Jun 2017 10:52:09 -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 <0ORU00M00P7EWD00@st11p02im-asmtp001.me.com> for internals@lists.php.net; Tue, 20 Jun 2017 14:52:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=04042017; t=1497970325; bh=qEVjUl0L8KCa5KDAkKGPy4GiRsn6pAwgIxZEVefbryg=; h=To:From:Subject:Date:Message-id:Content-type:MIME-version; b=Xkc90CGSYFCP11S3Qp3o0bAA7RlCklfIznSTgkydZyF7VB6Mhjn8E4/H4izACcowD uaYThua8gytQJYNYH70KHL9vQpaLIgkWHZfLFXaQtVmAGJkAJYlTi7LWVS3ClKTHNf 0OEzveI6Ik9dxt2ZKe8Y5PasSO3x2Ad9Tu7+5xXb3LArBjKPBZZ2BA9kAPeoEZqQPo Q8aQbaABQ3dKeFcxOh3Ms3g3M8wXJEPAmornmq7VA+9MxAqOy1xCen6989OKBTfpUm v1cZZAPhNwool3ZwMLwgQYiGkLkG6zsh3QTtJ2KBThxBjP3e3dYtFm/JcFMgSrEc0e j/bqD4pxkI0VA== Received: from localhost (st11p02mm-webms001.mac.com [17.172.220.222]) by st11p02im-asmtp001.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) with ESMTP id <0ORU00CT8PAPPK10@st11p02im-asmtp001.me.com>; Tue, 20 Jun 2017 14:52:02 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-20_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1701120000 definitions=main-1706200263 To: Rasmus Schultz Cc: Levi Morrison , =?utf-8?B?QmrDtnJuIExhcnNzb24=?= , Fleshgrinder , PHP internals Date: Tue, 20 Jun 2017 14:52:01 +0000 (GMT) X-Mailer: iCloud MailClient17DProject115 MailServer17D66.26276-16A-2130-9729af27059c Message-ID: <5af0d005-2fe9-43e6-976d-6e10e1c5cc5e@me.com> Content-type: multipart/alternative; boundary=Apple-Webmail-42--92070a77-0e2b-48fa-a63a-88cf5db43cc7 MIME-version: 1.0 Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: ilija.tovilo@me.com (Ilija Tovilo) --Apple-Webmail-42--92070a77-0e2b-48fa-a63a-88cf5db43cc7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8; format=flowed Well, the Ruby/Rust syntax would serve us well here too:=0A=0A$things->for= Each(|$v| {=0A=C2=A0 =C2=A0 foo($v);=0A=C2=A0 =C2=A0 bar($v);=0A});=0A=0AO= n 19 Jun, 2017, at 09:43 PM, Rasmus Schultz wrote:=0A= =0AI actually like this syntax, but what would it look like for multi-stat= ement closures?=0A=0AA nested set of curly braces around the body would lo= ok pretty messy.=0A=0A=C2=A0 =C2=A0 $things->forEach({$v =3D> { foo($v); b= ar($v); }});=0A=0A=0AOn Mon, Jun 19, 2017 at 4:43 PM, Levi Morrison wrote:=0AOn Sun, Jun 18, 2017 at 1:44 PM, Ilija Tovilo wrote:=0A> Sorry, I wasn=E2=80=99t aware of that.=0A>=0A> Wha= t do you think of the Ruby/Rust style syntax that Levi proposed a while ba= ck?=0A>=0A> $someDict=0A>=C2=A0 =C2=A0 =C2=A0->map(|$v| $v * 2)=0A>=C2=A0 = =C2=A0 =C2=A0->filter(|$v| $v % 3);=0A>=0A> This one has a few advantages:= =0A>=0A> 1. It has syntax (a lot of) developers are already familiar with=0A= > 2. It has no ambiguities and is fully backward compatible=0A> 3. It=E2=80= =99s the shortest of all options available (two `|` characters and one spa= ce)=0A=0AWe determined that the arrow between the parameters and the expre= ssion=0Awould still be required. Given this limitation I think this syntax= is=0Aseviceable:=0A=0A=C2=A0 =C2=A0 $someDict=0A=C2=A0 =C2=A0 =C2=A0 =C2=A0= ->map({$v =3D> $v * 2})=0A=C2=A0 =C2=A0 =C2=A0 =C2=A0 ->filter({$v =3D> $= v % 3});=0A=0ASometime this week I intend to start another thread that nar= rows us=0Adown to two choices.=0A=0A --Apple-Webmail-42--92070a77-0e2b-48fa-a63a-88cf5db43cc7 Content-Type: multipart/related; type="text/html"; boundary=Apple-Webmail-86--92070a77-0e2b-48fa-a63a-88cf5db43cc7 --Apple-Webmail-86--92070a77-0e2b-48fa-a63a-88cf5db43cc7 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8;
Well, the Ruby/Rust syntax would serve us well here too:
$things->forEach(|$v| {
    foo($v);
  &= nbsp; bar($v);
});

On 19 Jun,= 2017, at 09:43 PM, Rasmus Schultz <rasmus@mindplay.dk> wrote:
I actually like this syntax, but what would it look like for multi-s= tatement closures?

A nested set of curly braces around = the body would look pretty messy.

    $= things->forEach({$v =3D> { foo($v); bar($v); }});


On Mon, = Jun 19, 2017 at 4:43 PM, Levi Morrison <levim@php.net> wrote:
On Sun, Jun 18, 2017 at 1:44 PM, Ilija Tovilo <ilija.tovilo@me.com> wrote:
> Sorry, I wasn=E2=80=99t aw= are of that.
>
> What do you think of the Ruby/Rust style sy= ntax 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 `|` cha= racters and one space)

We determined that the arrow betwee= n the parameters and the expression
would still be required. Given thi= s limitation I think this syntax is
seviceable:

   = $someDict
        ->map({$v =3D= > $v * 2})
        ->filter({$v =3D> $v %= 3});

Sometime this week I intend to start another thread = that narrows us
down to two choices.

<= /div>
--Apple-Webmail-86--92070a77-0e2b-48fa-a63a-88cf5db43cc7-- --Apple-Webmail-42--92070a77-0e2b-48fa-a63a-88cf5db43cc7--