Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88519 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35810 invoked from network); 26 Sep 2015 19:06:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Sep 2015 19:06:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.171 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.171 mail-wi0-f171.google.com Received: from [209.85.212.171] ([209.85.212.171:35605] helo=mail-wi0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/63-06395-A9CE6065 for ; Sat, 26 Sep 2015 15:06:03 -0400 Received: by wicge5 with SMTP id ge5so58285135wic.0 for ; Sat, 26 Sep 2015 12:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=IoptWO9DyvSpAg94R0MJgj6tMyRySWEbM+28s9xgqMg=; b=hCkAudpv6OUJWZACZVfxCuuw1k4tew/jVpLJPCcIp0ojeewmLFdLVuy/3Infwt1rBk R5gg+qzGAGJFhNzF21VVT5HCDj3wDtfwJGDAke0PoHCs0l7+QKsEBPbO0647Ue8MWt4D r9YJvr9M6rK8DCBCfrjgbW2TDwT5XNC+ctrsLE9RDczEfT4V1jlEX0qvOT743FrROvJ0 HYakzwd+RltSYEADU8Cs5eQ9mwENG+h2bpZiIZ65QdF3mqfG0eLg5eGLra9KDMbZ0iku LHIEhNpIrWjMW0fmxgc22GJDGqqQSipECydAkqQdvtdc4tm39115NKArGPe7DDNql+Zm kpnQ== X-Received: by 10.194.104.39 with SMTP id gb7mr12614898wjb.150.1443294359579; Sat, 26 Sep 2015 12:05:59 -0700 (PDT) Received: from [192.168.0.5] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by smtp.googlemail.com with ESMTPSA id hr17sm9539279wib.16.2015.09.26.12.05.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Sep 2015 12:05:59 -0700 (PDT) To: Levi Morrison References: <5606D0EB.3060106@gmail.com> Cc: internals Message-ID: <5606EC93.4020003@gmail.com> Date: Sat, 26 Sep 2015 20:05:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Arrow function expressions in PHP From: rowan.collins@gmail.com (Rowan Collins) On 26/09/2015 19:37, Levi Morrison wrote: >> Thank you for the feedback. I feel like the rest of what you proposed >> was a bit too far outside of the box. For what it is worth no token >> after the paren is necessary – you could do `fn($x) $x * 2` (or >> `function($x) $x * 2`). I think this is a case where more syntax >> helps. > Here they are on separate lines so you can see things more clearly: > > $output = array_map(function($x) $x * 2, $input); > > $output = array_map(function($x) => $x * 2, $input); > > I think the arrow helps. I meant more that the lack of parens around the whole expression looks odd - the => is no longer just an operator linking two expressions, it's an arbitrary piece of syntax inserted just because it feels like something should go there (and I agree it does look more readable than nothing at all). How about a variant on existing curly braces: fn($x) { $x * 2 } lambda($x) { $x * 2 } Or the arrow inside the parens: fn($x => $x * 2) function($x => $x * 2) My point is that there are plenty of other variants, if we're no longer mimicking the "(params) => expression" syntax of other languages. Regards, -- Rowan Collins [IMSoP]