Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112225 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 75263 invoked from network); 11 Nov 2020 18:37:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Nov 2020 18:37:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 06BE6180540 for ; Wed, 11 Nov 2020 09:59:46 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 11 Nov 2020 09:59:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1605117582; bh=06LhAGu7mVkY5ZXeiyNznFkmko/F0jYkVaocI2unAoc=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=ju+MzaugNw58wruccaMp928l//mp7fFDmrEgNLCTqL8ok5apbFuhePopuvU0kPNDE eYomUMA3vsQXuIEJhGW4AsLDUMkJpv4uJghhNO4PVbmqc7yUvrpe6RHEXlVhX0+wmR LiZfkZzC/mpsQDPzbyVEBI+xXvAfTbhOwfQLFGGo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([84.179.233.71]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N7i8Y-1kHeAu0jY2-014hGE; Wed, 11 Nov 2020 18:59:42 +0100 To: Dan Ackroyd , Hans Henrik Bergan Cc: PHP internals References: Message-ID: <55e200cf-ed16-e935-4e09-728ce3362cba@gmx.de> Date: Wed, 11 Nov 2020 18:59:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:2oVx3r7H0z27AIDljptYT51IjNauxfP44CNAfMp/+Aaz1tZQ+10 t4Zzw+tit6BBl1NLnkqLZPeHEpmdb/EKRORzZlHVN5YGDX9b6ocVF5YXVSXkbZoGUMockie E+HjDeePdeUBxzXV4mLtFfv0+NPsp5u6aZz7EbulpD3++7cJj7xAU9iC4JVV9W/tB8FAG9s GuxuJoHgoy26/H6TMuNsg== X-UI-Out-Filterresults: notjunk:1;V03:K0:jYXoSx+MEX4=:raiJm3LbxnO4kE2j/5zyja CvV895O81tLyF6uoR/0lLmzhX1TlQt4txB4OUO/UubB0DdRN3lhwVkPNty/C4c7HIYluCNcql MDL4dAH3txiVcjUogUT0KuZqlPpkSOzYTN79FTP2nbEbSdXV/jIYMRQxVHzFt5XA8z/y5FPu3 AnbT2mxgz8eYtje/1/3nPhs/mQ7HiLhPWeH4NnCe1INVDRYcBm/G5ywV8Sb2YvPa/2yNY1mpG umINIzjdNq1yj5QJOS7ENcRGs8vjWaNtUl9G5+lhwde5cha9kclxDx9LfS1VW/V8hcK5jlcxW t4CTqsjl8n96CVTvEw3/eL4CFmQSOXS9qNz9tfoyjDh3SOy6g4C8Ii+5lGjXEhrrdYRIk5Q+x uRYMaao0bu2c2ux3Y3lCh/CQR7fZaNu1ptFIv3d/rrfKAdMMFOIGp0Ht3c/WFwnx1c6NUo6Ya Jw7GCFsZnznnH0dosUsURY8Ox1hFKc8pH8jJ1eeFNqvTQ6su5ApWWlE+dRF/2j8S3aozqb9DG GedBGD3pNqwoOPD3jIePYyso2Z95IfYY2TOs3t9YWY94wayqJ2VW/r+Odd06SFazaMCIbfdhR EA++H3vIDsJ4HxGdrhK05LUmxrxwXR+1RX77qFg5kLkhLsPqeGPTShJsX6T2/nDXrpcF9LU6R U4Lb9pIK1J9b93S9gtAdEjk1mMAby8O7YZPuj6+TKzZbL5SrdQA3AjbCywsgtXBPmEAgU66Pt DyFpJfRJ2H0UE7ZfeBO4lKnk3Duaxjvhf5o/O31IOCm60XO1YLnflJFHApWC6NQBvmrRT/vYZ NE+57VsKwp7fEtG01M0Z4J+LgQtmPGZSanpkPrn7XLdvrzMnWO5l8//Pu7ESR17Yhuv+B+Rjt 9aUmgqACLYjnFi/qM8XQ== Subject: Re: [PHP-DEV] [RFC] Draft - Closure self reference From: cmbecker69@gmx.de ("Christoph M. Becker") On 11.11.2020 at 18:39, Dan Ackroyd wrote: > On Tue, 10 Nov 2020 at 17:39, Hans Henrik Bergan = wrote: >> >> something i'm missing from Javascript is the ability to give names to >> closures, ...the name is optional, and only visible inside the closure >> itself, and unfortunately this is not legal in PHP, i wish it was. > > I really like that...but unfortunately that wouldn't work in PHP. > > In JS, when a function is declared inside another function, the name > of it is limited to the scope of the containing function. In PHP, when > a function is declared inside another function, it is put into the > current namespace's global scope. > > Changing how scope works in PHP would be too large a change for just thi= s. In JavaScript, a named function expression is different to a function declaration: var fn =3D function foo() {console.log('blah')} foo() =3D> Uncaught ReferenceError: foo is not defined vs. function foo() {console.log('blah')} foo() =3D> blah So the named function expression is still an anonymous function; the label is only defined inside of the function body. Christoph