Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88582 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31950 invoked from network); 30 Sep 2015 16:20:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Sep 2015 16:20:39 -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.170 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:34593] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/F0-24989-7DB0C065 for ; Wed, 30 Sep 2015 12:20:39 -0400 Received: by wicfx3 with SMTP id fx3so205701273wic.1 for ; Wed, 30 Sep 2015 09:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=5rLDiNciUbYbPlok+XhaTrXOlKu8OT6x1lMiMzJqTTY=; b=mmXtH7rrVnGWB1BapgEboEtUv7FM4vOQR0FZ46ES44di8nISRS2HQo4poWVW6salAf 8tY8S0EeOGvihiU0/sp9/k8Kw6SZfXhZUZMbF5uS0HeO3V4XDs4hl3tILX2DMIz145pP DvQLdtdWVNoVM59KZqVl9BdlZ9bVTMtbTOrw8gZ2W0GpSETKfC30bUMSWo9WOkE35lDT tZ1525tjhtuES+3E3LTiIRUGI26IEvYZUb0Apa9MuisHhZfNgv1WQuaxF9/iTUpIrY6e 3rzlGxpFd+cUVS/g1vG0PDcON74EvuK/Qkgl1dkO6HzZqtVZLlBWifo9n5JKd/d/7JNg 8oMA== X-Received: by 10.180.104.65 with SMTP id gc1mr34169794wib.67.1443630036011; Wed, 30 Sep 2015 09:20:36 -0700 (PDT) Received: from [192.168.0.161] ([62.189.198.114]) by smtp.googlemail.com with ESMTPSA id gt4sm30413431wib.21.2015.09.30.09.20.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2015 09:20:35 -0700 (PDT) To: PHP internals References: <560BC324.7010901@gmail.com> Message-ID: <560C0B96.1040601@gmail.com> Date: Wed, 30 Sep 2015 17:19:34 +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: 7bit Subject: Re: [PHP-DEV] Arrow function expressions in PHP From: rowan.collins@gmail.com (Rowan Collins) Marcio Almada wrote on 30/09/2015 15:49: >> That's not to say that automatic capture is an absolute blocker, but I think >> >"the internals community is divided on it" is a reasonable summary. >> > > That's the part I couldn't comprehend in the discussion. Auto import > is basically the most interesting reason to have short closures on > PHP. It's also the biggest departure from existing PHP semantics - PHP's scoping rules are remarkably simple compared to other languages: everything is local unless qualified. No scope chains like JS, no "my" and "our" like Perl, no short-hand references to properties of "this" like Java, etc. "use", "global", and "static" can all be seen as explicitly importing variables into that local scope. Breaking that rule is something that needs to be considered very carefully, and is a lot more than a minor detail of syntax. I note that C++11, although it has a very compact (and keyword-less) lambda syntax, still requires an explicit list of captured variables; unfortunately, we can't just copy that syntax either, because we've used [$var] for array construction. But it does show that "short closures" and "auto-capture closures" are two different features; we could save up to 17 characters without changing behaviour if we could eliminate the keywords "function", "use", and "return". Regards, -- Rowan Collins [IMSoP]