Re: [RFC] [Discussion] Short Closures
| From: | Rasmus Lerdorf | Date: | Tue, 01 Sep 2015 02:55:00 +0000 |
| Subject: | Re: [RFC] [Discussion] Short Closures | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-87969@lists.php.net to get a copy of this message | ||
> On Aug 31, 2015, at 18:04, Bob Weinand <bobwei9@hotmail.com> wrote:
>
> From the RFC:
>> all variables used in the body of the anonymous function will automatically be bound to the
>> anonymous function closure from the defining scope
>
> The implementation is not capturing all the variables from the outer scope, but strictly only
> these accessed by the variables in the Closure itself. Hence that shouldn't be much of an
> issue.
This magic scares me. I made a very deliberate decision In the very first implementation of PHP to
avoid scope side-effects like this. Inside a function everything is local unless explicitly declared
not to be. This has carried through for the past 20+ years in slightly different ways, but the basic
rule has stayed consistent even for closures. Unless explicitly declared via a use clause, every
variable inside a closure is local and no cross-scope variable name side-effects are possible. I am
not convinced that this feature is worth breaking that longstanding basic tenet of the language.
-Rasmus
Attachment: [application/pkcs7-signature] smime.p7s
Attachment: [application/pkcs7-signature] smime.p7s