Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99372 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20498 invoked from network); 5 Jun 2017 18:36:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2017 18:36:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.192.180 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.192.180 mail-pf0-f180.google.com Received: from [209.85.192.180] ([209.85.192.180:36726] helo=mail-pf0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DB/74-27119-0A4A5395 for ; Mon, 05 Jun 2017 14:36:17 -0400 Received: by mail-pf0-f180.google.com with SMTP id m17so86815649pfg.3 for ; Mon, 05 Jun 2017 11:36:16 -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=MyXxCpaD8v95egN8LLfyu4fHl3xO4d8dJ8DaPdcVrfo=; b=QHRiJUzGTEhsBYANT5umZrI0Xv0beJr6d+6irDUTaSTbuoGm2ZFIfrNMlajaB7W1+V hjUEn0SzFXOpb3ygfG1iNLesv2fvOqqMUzuW07o7vWrIude4Y6KZGrs5CbsAmxalv/ud Ln2NJSVHOcR0nDwKKPHWWw9Vk7D2LpJMa/wU3O/fDNklkMUvG7Y2ly4R+ggTNhFdQGDh q1dkLxS6mj6XEgUJS/XnTBtqYfbhEoVfw85triHUN5ArIT6lll0Ae7jh2N6Zad7x33+S HpqJY8E/+5wVgHnVzUGxqQff7uXEYGjCOjIE19DyHMl7VfyqlrGm+hKGnoMlnAlEY1OZ gOZg== 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=MyXxCpaD8v95egN8LLfyu4fHl3xO4d8dJ8DaPdcVrfo=; b=LaBdteUfVnQQ1RctXC5zSc5VZNIPcO/L7Q6RLD1Erwg5FprKOYG6VyzV/orLkn21ZT Xp7LQQCxlZMUY0pbif6Q+D1oheFHbKBrYcKjhSeAc4ehgIkbW1tg7F9vJIKbxhcHM7CR fUU8jUoso1Hi0j7yL/wz6XW+8Z8lVCKqu73phVlzpvEdIeG3kd1OafTo/MnRp/V+ew23 BEyuhaLaC7Vx0tNFG5ut9AsVNckyiNBU2AI+kuDkjsSZJUTaUA624MLw7A/+NqL3Weuz QPJNEuJstsHpRb4lczsK7QyEGQKTR/EnhoqE//rFj6kRI8okqNHiYtEAku6etE8Kf3PX +HzA== X-Gm-Message-State: AODbwcACQrxFF8EqKisHGi3SCDG/G3mjefj3qGSCI6sKvtcza5RlAh61 17hHWeP7rybauyJJ8uCchXFWQehw5Cae8mhbrg== X-Received: by 10.99.127.19 with SMTP id a19mr22890375pgd.213.1496687774206; Mon, 05 Jun 2017 11:36:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.131.23 with HTTP; Mon, 5 Jun 2017 11:36:13 -0700 (PDT) In-Reply-To: <2f9e73c9-444a-11d0-459a-e261ea8a7080@telia.com> References: <6357d97c-3f2e-4cf8-cb1f-cb7f7ccccf7c@telia.com> <7eaef49b-bf60-9aa1-e812-8430164e3178@garfieldtech.com> <3F920987-38CB-42DD-888D-824430C36F14@gmail.com> <2f9e73c9-444a-11d0-459a-e261ea8a7080@telia.com> Date: Mon, 5 Jun 2017 20:36:13 +0200 Message-ID: To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Cc: Rowan Collins , PHP internals Content-Type: multipart/alternative; boundary="94eb2c1b592e1f682e05513ac739" Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: rasmus@mindplay.dk (Rasmus Schultz) --94eb2c1b592e1f682e05513ac739 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ugh, you're right, that's totally unreadable... the =3D> is far too ambiguo= us with array syntax, I agree. How about just a thin arrow? (params) -> expr If the parens around params were required, it's not ambiguous with the trailing -- operator, is it? $foo->bar(($baz) -> $baz + 1); Consistent use of parens around the params might make closures a bit easier to spot in the wild? On Mon, Jun 5, 2017 at 8:11 PM, Bj=C3=B6rn Larsson wrote: > > > Den 2017-06-05 kl. 19:55, skrev Rowan Collins: > >> On 5 June 2017 18:17:06 BST, Fleshgrinder wrote: >> >>> Could someone explain me again what the problem with the simple >>> fat-arrow and normal parenthesis is? Cannot find it anymore (too many >>> messages in too many thread I guess). I would guess that it has to do >>> with the arbitrary look-ahead that is required to check for the fat >>> arrow before the lexer knows that this is a short closure and not some >>> parenthesis that simply groups something. >>> >> I think it's not just a case of implementation problems, it's actually >> ambiguous with current syntax: >> >> $foo =3D array( ($x) =3D> 42 ); >> >> Sure, those inner brackets are redundant, so it's not likely to break >> much actual code, but it's kind of weird to have this one case magically >> turn into a closure, when anything else you put in those brackets would >> just be used as the array key: >> >> $foo =3D array( f($x) =3D> 42 ); >> $foo =3D array( ($x+1) =3D> 42 ); >> $foo =3D array( (42) =3D> $x ); >> $foo =3D array( (X) =3D> 42 ); >> $foo =3D array( ($x) =3D> 42 ); >> $foo =3D array( ("$x") =3D> 42 ); >> >> Even if we could teach the parser to understand it, I'd personally be >> against it for the difficulty of *humans* parsing it. I find shorthand >> closures hard enough to read anyway, especially when people suggest thin= gs >> like ($x) =3D> ($y) =3D> $x * $y * $z; >> >> Regards, >> >> +1, think you nailed it here :) One of the reasons I prefer the =3D=3D> > syntax. > > r//Bj=C3=B6rn > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --94eb2c1b592e1f682e05513ac739--