Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99251 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91776 invoked from network); 30 May 2017 03:45:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 May 2017 03:45:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.223.181 mail-io0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:33122] helo=mail-io0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/AB-34073-7CAEC295 for ; Mon, 29 May 2017 23:45:11 -0400 Received: by mail-io0-f181.google.com with SMTP id p24so49714860ioi.0 for ; Mon, 29 May 2017 20:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=OFt2wr/Nnxq3IYaShRl326HUeDyus8umWy/pzG0mPHo=; b=rKkDIJ8IyDC26jsQSAwZyG1Aso0jrAsaK8MvS/Lr5e99WPD1EdPq6t/MWEfoJswvTw bjxD4k0CFCGAQvnwtpGa9x47dkClBYVItxNfhjCbXeqZib3OS5ThQ/0PLgXpalUC30KT pqGuS0RDsHmfTry181+jtFVXbaupIi6tO9eAKxduJGyLYVo6nntD2Jx3pADclkg3hlC8 OIbBUwD4c2YtWg+rChjtNNbc7FmJJRDKN8tB/dTx//pcQ3C25olRPzEcpezASFqk9ZEl Q/7vX2y84giAmBhQ7TKNiLE6s8Lc5U7v9PEvp8aSXH36dUr/n1Tc2MHitvDBNZIscoRc hXoA== 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=OFt2wr/Nnxq3IYaShRl326HUeDyus8umWy/pzG0mPHo=; b=ZqIz/iYq2MkKNnQYw5MYvTMFgNiuCxh78ugnM1P6uWYVqtCB7o/qALDg5pOB4OzRgM R3gDjxIm9jr3bD36InbbAhW7lgKXxd65RDXy42HVyz1aMlJgJrn9EDAnJWFXXYLHp3m1 NMp+9igaKKpA3p3HPkfjY1YHmHH0XcKNxjIBP6Ys3c3LvL7MF1apvmfAdjy8r9H4CBf1 Q/YW2I/KBx/Z0KMPN+DKyrpBKSCj8dW/JbqOOnII5kfQtY1VCTADFmOOs7qzCKrIq2+x RsTq2WGpMe516nkfzldp9F8wV5b2YEp3LXHusZEvG8/5DOPM9cD4RtBQ/leZEK+9YBop 30yQ== X-Gm-Message-State: AODbwcBWx6Ez99SRVmcnQsLe8+0BW/zy5p7jB/0t0JW9djKEGROcYutE vaV+qiebwWilDwgjLZNHlyTktuvfFg== X-Received: by 10.107.174.157 with SMTP id n29mr16423480ioo.39.1496115908839; Mon, 29 May 2017 20:45:08 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.107.12.159 with HTTP; Mon, 29 May 2017 20:45:07 -0700 (PDT) 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 21:45:07 -0600 X-Google-Sender-Auth: wadR9-YlV-raEtr5DEMIkpWWJgw Message-ID: To: Sara Golemon 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: levim@php.net (Levi Morrison) > 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. I already mentioned the changed behavior. What you've indicated here is not a special case of that same behavior since `[]($x)` would be prefix to an arrow function which binds the arrow to the closure and not the array. > 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]). You would do: [=, $foo, $bar]() => $foo * $bar if you really wanted to bind everything explicitly. I haven't written a full description in my previous thread but it's all doable except I'd want to verify the grammar disambiguation with an empty `[]` specifically.