Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88539 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39570 invoked from network); 29 Sep 2015 06:23:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Sep 2015 06:23:22 -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.178 as permitted sender) X-PHP-List-Original-Sender: pajousek@gmail.com X-Host-Fingerprint: 209.85.213.178 mail-ig0-f178.google.com Received: from [209.85.213.178] ([209.85.213.178:34376] helo=mail-ig0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/25-17200-95E2A065 for ; Tue, 29 Sep 2015 02:23:21 -0400 Received: by igcpb10 with SMTP id pb10so72911324igc.1 for ; Mon, 28 Sep 2015 23:23:19 -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; bh=F9c+MNsDLeOBqhq4OqJ76/rNrj7+SvWMhD2vcPUNybk=; b=Et0XEe32qXew2XMIY+UMksRCh5V4gXSyB9es7S/1yCJwx4ouFi/fa3swaeGe1JJZpr ar3frRD0iwJtaBLlTrbAZ82Ch4oczT8xV/1lJbLQX17e3QAfdcSJ7Vaq5EJjGpjenbLe /HN2/a76knLANlRw0ptm66ETrKO5Sy6UZuj5CQTQabs0L8+1TctFWcMPO1LYGB+XARgF qnzt/PBilHCKOQYa05LQxZuDDIf6za8XSD3LZzxgfelhQ+PPMKgXiEBqmTATosEzkOAy 2OJwGCLfGfZWmI/sd0EHk0PuTNzulS0IxrOrertOHH/wF80S01yvNDq/e350tT5XHF/n XMQA== MIME-Version: 1.0 X-Received: by 10.50.138.11 with SMTP id qm11mr10393051igb.77.1443507799317; Mon, 28 Sep 2015 23:23:19 -0700 (PDT) Received: by 10.107.189.132 with HTTP; Mon, 28 Sep 2015 23:23:19 -0700 (PDT) In-Reply-To: References: Date: Tue, 29 Sep 2015 08:23:19 +0200 Message-ID: To: Levi Morrison Cc: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Arrow function expressions in PHP From: pajousek@gmail.com (=?UTF-8?Q?Pavel_Kou=C5=99il?=) On Tue, Sep 29, 2015 at 12:52 AM, Levi Morrison wrote: > > I do not think it is feasible to make the parser do backtracking or > anything of that sort. How do others feel? > >> PS: the [fn($x) => $x * 2] seems ambigous, from reader's POV; key of >> the item is result of fn($x) and value is $x * 2? Also, it would be a >> huge BC break with not allowing you to name functions fn(), wouldn't >> it? > > This is not a huge backwards compatibility break, no. It is a small > break. This is one reason `fn` is not necessarily what I will be > proposing and want to hear more feedback. Note that the `function` > version wouldn't be possible to be confused *at all*: > > // function($x) isn't allowed for function name > // so this is very unambiguous > [function($x) => $x * 2]; > > Also note that using closures in array literals is not really that common. When you choose the function($x) ~> $x * 2 (or with ==> or => operator), you end up saving around 5 or 6 characters from the "long declaration", ending up with "not-so-short closures" instead. You save a little bit more if you have the implicit "use", but that's one thing people are torn about, by looking at the discussion about the RFC, but I think it's too long, for "short closures". Would making the parser do some backtracking be really that bad - especially since the option would end up with the IMHO most convenient option for actual users of the feature?