Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99250 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89641 invoked from network); 30 May 2017 03:15:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 May 2017 03:15:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 74.125.82.44 mail-wm0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:37677] helo=mail-wm0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/5B-34073-FD3EC295 for ; Mon, 29 May 2017 23:15:44 -0400 Received: by mail-wm0-f44.google.com with SMTP id d127so79413862wmf.0 for ; Mon, 29 May 2017 20:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=FG7vtnEBxNVyRxyT8o5hV4o3hQCGwQFeSAIORzkN6ow=; b=wvfF/9+Kb+UAZFSp7eGIuSyILFkkwDVxJduCi79wnSjvnYcJP67+yf2rG4ckUDHAmZ 04lL3yaAPAFWZItGURZP4UT8RzYrVd6uSY6AuKNPKjepaOasmMpsC1iJtFlrxJWnVKNx Bnh1JnAjy9wvdzQoNLHpiVUVggBQEZvBqGcWdfYn+rDDqfv5KWnIO+gDlkM2aiaHNRF2 fu70/jVcTEqjJHOUzYyYvKaAfx4tG6rh6lqW6CxPo0522ysvpJm1Zg8Lwy3vx66BspYf pEMDBJH9jahrYEH6HQ3QvWWlEdnlfpVOe3cj8+9HaTmvZ9Mv7tLREIfL8NW/YKm5ggmf WDFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=FG7vtnEBxNVyRxyT8o5hV4o3hQCGwQFeSAIORzkN6ow=; b=A4eo2TKpNo7k61zLAG3sk6ogt4f8W4yJvCYS1YSA+MB+KlEZe9ULqpMI8/LzjWOxk5 jsm8uv8hNiiHZryNIqLyJaCgmkkGn6nEoJ3Hl3hEoOkDeeY1ptHLSAAxBEHi/xnzNMCr Kt4f97ELOE3x2mVAK4UThWfjyjMSY9W6ZmxfnMTNG7nE7qXbyZ/knDlihTsoid/dCybr kqlyz2S71fDL3l0kfWq5RGDE48JbUS0bnIA+wDbSJcpHy5c2P7COFD9EwBXR7v4ZSMYl VPQAKaKpoSXE+nhAp8xZWMbYzwgsL6taVnr+AgXx8CE2k5bfIUabTYYoQwqOUWnIUzk7 L5GA== X-Gm-Message-State: AODbwcAk4TO7YSMGUEto9DesR1Z5Q4Zr+qj9LCTBsu1APZZCZ8KJHDjD bQ1WmUiuOx5VOyvAT9ssRchPEAGh+k0x X-Received: by 10.223.179.199 with SMTP id x7mr13983908wrd.72.1496114140331; Mon, 29 May 2017 20:15:40 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.157.38 with HTTP; Mon, 29 May 2017 20:15:39 -0700 (PDT) X-Originating-IP: [2604:2000:dd18:cb00:1d35:5fc6:37be:7398] In-Reply-To: References: <97bb5051-6413-b78a-e981-ad8858caec4c@gmail.com> <8d4ee559-1ad2-4d65-ae4f-207e59f056e3@Spark> <61DC1C28-CAF2-45F4-8D9F-A66BEA2E90B1@gmail.com> <3942113e-f83a-444f-bbc2-462c70d67c65@Spark> <20db9b97-5313-057d-db56-920ccb758558@telia.com> <877970f0-b22d-a8b9-9ad4-6fc9139a9b34@telia.com> Date: Mon, 29 May 2017 23:15:39 -0400 X-Google-Sender-Auth: 5a43dUn77OrgFU7MY5eeqixUsX4 Message-ID: To: Levi Morrison Cc: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= , internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC][Discuss] Arrow Functions From: pollita@php.net (Sara Golemon) On Mon, May 29, 2017 at 10:48 PM, Levi Morrison wrote: > Based on the discussion there are a few different syntax choices that > we probably just need to vote between. It's a feature that people seem > to want but everyone seems to prefer a different syntax choice. > > 1. fn(params) => expr > 2. function(params) => expr > > 3. (params) ==> expr > 4. (params) => expr > TL;DR - I'll be happy with whatever the group can agree on, with a personal ordering of: 1 > 3 > 2. I excluded #4 because I just don't see how you disambiguate this: [ ($x) => $x ] . It's already valid syntax: https://3v4l.org/NedDu . With zero or 2+ args it's disambiguable, but one arg has to be possible or it's a no-go. > This is why everyone is so divisive. All options have drawbacks. > Additionally some people don't like binding by value and would prefer > ref, and others really would be against by-ref. > Again, I'll accept the group's opinion because I don't care enough to block it, but I'm registering my preference for the record, as by-ref. > Which brings me to an option I don't think was ever discussed on list: > > [](params) => expr // binds no values > [=](params) => expr // binds by value > [&](params) => expr // binds by reference > As a C++ developer, I have no inherent problems with this **in theory**, but I agree with your statement that it's a bit symbolic soupish. I also suspect that we'll run into grammar ambiguities. Imagine: [ []($x) => $x ]. This is current legal syntax (at the point of compilation) because it *could* be interpreted as an array with a single element (value $x) who's key is the result of calling a function defined by an empty array passing a single arg ($x). It's invalid at runtime (See: https://3v4l.org/IcK3B ), but that means special casing our way around the ambiguities. Further, if we're going to follow the C++ model, we'd be well suited to allow explicit per-var by-val/by-ref syntax, e.g.: [$foo, $bar]() => $foo * $bar Again, this is legal syntax to the parser, but now it's even potentially current legal syntax to the runtime (assuming is_callable([$foo, $bar]). So yeah, probably doesn't fit PHP, but good thinking outside the box. :D -Sara