Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88652 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 260 invoked from network); 3 Oct 2015 08:06:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2015 08:06:47 -0000 Authentication-Results: pb1.pair.com header.from=pajousek@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pajousek@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.172 as permitted sender) X-PHP-List-Original-Sender: pajousek@gmail.com X-Host-Fingerprint: 209.85.213.172 mail-ig0-f172.google.com Received: from [209.85.213.172] ([209.85.213.172:34828] helo=mail-ig0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B4/20-31315-59C8F065 for ; Sat, 03 Oct 2015 04:06:45 -0400 Received: by igbkq10 with SMTP id kq10so31912949igb.0 for ; Sat, 03 Oct 2015 01:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=IWWdD29lYYDuUeMqZ32p/xkljdVtS71MXcZvOHgvsgo=; b=w+doNGM558MAqQjo+MCTEkp732046sEmfOZkSnxWo1s9UdIROnFXUp+4xOZmc6ki3H eCJbstJHoy3hgKVN+bh/gv2qnapaCYPTN1rh0fPW9ETLu7pZyIFZ80FQVoC5MXgak+qi vPwCMvOthqGHGgLbOQVhcqzNffSCv6Td03gOWJrN3IWp4JIIeoUfgVqydcTvaghH/fqm nP2kWr2UcAZXGi6IPdpVl3BY+KY6aBfI/gE2nQ0Z/rk5wPBWF4fo5pRKl5ymo4eYSvND 5iP+lFB0/ARouRG4Z+CFCkvbXXitGOr+xyQlOEpOswuI/93sJVhxYs/VHozeAXLdY32T VsKQ== MIME-Version: 1.0 X-Received: by 10.50.55.68 with SMTP id q4mr1112784igp.77.1443859602695; Sat, 03 Oct 2015 01:06:42 -0700 (PDT) Received: by 10.107.189.132 with HTTP; Sat, 3 Oct 2015 01:06:42 -0700 (PDT) In-Reply-To: References: Date: Sat, 3 Oct 2015 10:06:42 +0200 Message-ID: To: Levi Morrison Cc: internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Arrow Functions From: pajousek@gmail.com (=?UTF-8?Q?Pavel_Kou=C5=99il?=) On Sat, Oct 3, 2015 at 1:17 AM, Levi Morrison wro= te: > I messaged the list about this feature before I had the RFC written up > for it. The RFC[1] is slightly different from what I proposed in the > previous thread, so please read the RFC to make sure you understand > what is being proposed before replying here. > > Here's a small example: > > $y =3D 10; > $result =3D array_map(function($x) =3D> $x + $y, [1, 2, 3]); > > // $result is [11, 12, 13] > > Thanks for people who have participated in conversation so far, as > well as those who participated in Bob's short closures proposal as > well. > > [1]: https://wiki.php.net/rfc/arrow_functions > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > Hello, thanks for another proposal on this feature. :) As I said in the previous e-mails, I'm not really fan of the "function" prefix - because it has the same prefix as the "long declarations". Just by removing the { } for =3D>, the autobinding also goes into place* and also only one expression is allowed, but the "beggining" stays the same (that being function ($x)). The function keyword also "collides" with the future scope with multiple statements. function ($x) use ($a, $b, $c) { $z =3D foo($a, $b); return $c($z, $x); } function ($x) =3D> { $z =3D foo($a, $b); return $c($z, $x); } Now the possible confussion with the different scoping rules would be even bigger, IMHO. (Disclaimer: I am huge fan of those autoimports and think that without them, the RFC doesn't technically bring anything important.) Also, I'm not a fan of the "fn" prefix, because then you would have two ways of writing "function", and people would probably want being able to use "fn" for named functions as well, bringing inconsistency into language. Also, this would requiring making "fn" a reserved word, breaking some applications - wouldn't it? Personally I'd prefer the \ prefix you also mention as possible in your RFC. It's also AFAIK used to denote lamba expression in another languages already, so it might be familiar for some developers? \(int $x) =3D> $x * $y; \() =3D> foo() \($x) =3D> \($y) =3D> \($z) Yeah, this looks pretty nice. Althought I'd honestly really prefer the Bob's syntax, but I understand that you don't want to make some engine hacks to make it working - but from userland developer's POV, that one was the best (speaking as someone, who would use the syntax daily). -- Regards Pavel Kou=C5=99il