Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88601 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97209 invoked from network); 1 Oct 2015 11:07:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Oct 2015 11:07:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.177 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.217.177 mail-lb0-f177.google.com Received: from [209.85.217.177] ([209.85.217.177:33461] helo=mail-lb0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/34-04700-4041D065 for ; Thu, 01 Oct 2015 07:07:49 -0400 Received: by lbos8 with SMTP id s8so6989847lbo.0 for ; Thu, 01 Oct 2015 04:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:subject:references:date:cc:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=EfvnInCXT3wgDTdiP4p4KgeSOqedrFjtTciIeJxWJCk=; b=uEufBVDuDXotllBZROCST8/t+Ccpg+Wn0kwtMsRtFTAC0e+7JTusFFEFbaj0LULW4v TU8xSWKS55x+mraseTCuOciQZn7u5lNQAuox9io27ONZb+6YCKp00OszHFZoncCGZ2nR xLaHVr4b0ZNztw5de5Hg4vBS3bmnfuTFzrCW8zoBXgi8+rk3C6BYisNZAq4s8wlQgR0/ ZtsyfRmEVOFmt9l8r9p4ODJstUVSGwbygvUpGRxpv/StJVif9cZK1GDa9z771Upzxbau ri573EwpR2XaKacYVs2sewm42vq/iUEByMocgUZ6z2WZu2VhIO7U3RlZ1Eh9kKj3vHSa ITcA== X-Received: by 10.112.32.72 with SMTP id g8mr2594371lbi.22.1443697665475; Thu, 01 Oct 2015 04:07:45 -0700 (PDT) Received: from nikita-300e4c-300e5c-300e7c ([185.62.192.230]) by smtp.gmail.com with ESMTPSA id 100sm605582lft.42.2015.10.01.04.07.44 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 01 Oct 2015 04:07:44 -0700 (PDT) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: <5606D0EB.3060106@gmail.com> <560D0F94.8060009@gmail.com> Date: Thu, 01 Oct 2015 14:07:43 +0300 Cc: rowan.collins@gmail.com MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <560D0F94.8060009@gmail.com> User-Agent: Opera Mail/12.16 (Linux) Subject: Re: [PHP-DEV] Arrow function expressions in PHP From: inefedor@gmail.com ("Nikita Nefedov") On Thu, 01 Oct 2015 13:48:52 +0300, Rowan Collins wrote: > Levi Morrison wrote on 01/10/2015 04:06: >> I'm going to ask everyone to stop saying that auto-closing is bad >> unless they also provide a demonstration of why it was bad. > > Please see my e-mail from last night, or Rasmus's in the original > thread. It is "bad" (or, controversial) because it is a fundamental > change to PHP's scoping rules, which currently treat all variables > denoted by "$foo" as local to the current function, without exception. And yet we have super-globals. You can also access variables of one script's global scope from another script's global scope without importing or anything like that. I wouldn't say that PHP has or follows any idiomatic "way" of how scopes should work, it's just evolutionary. >> I'm also going to ask everyone to stop suggesting new syntax for >> importing variables. If use() is a pain then auto-importing the used >> variables is a good solution. If it's not a pain why are you >> suggesting new syntax? > > Because the feature is being described as "short closures", or as a new > syntax, so people are looking for ways to make closures shorter without > changing the functionality. > > If auto-capture is the main feature you are interested in, and syntax > just a by-product, then it might be sensible to make that clear. As a > straw man, it would be possible to have auto-capture closures with no > new syntax at all, e.g. function($x) use(*) { return $x * $y; } I believe Levi's and Bob's intentions are not to introduce auto-capture but to add short closures, auto-capture being a tool that works best to help in achieving this. `use(*)` just as long as `use($y)`, and the shorter version where you need to separate args from uses with semicolon will be harder to read (ex.: `fn($x; $y) => $x * $y` vs `fn($x) => $x * $y` - it's not obvious at all what semicolon does. Whereas with auto capture you can at least guess that this variable will be captured from defining scope, if you don't know how this feature works).