Re: [PATCH] [RFC] Closures and lambda functions in PHP
| From: | Christian Seiler | Date: | Wed, 18 Jun 2008 16:37:07 +0000 |
| Subject: | Re: [PATCH] [RFC] Closures and lambda functions in PHP | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-38357@lists.php.net to get a copy of this message | ||
Hi,
[I'm going to collect here a bit:]
Stanislav Malyshev wrote:
lexical in the proposal binds to creator's scope, not caller's scope, as I understood. Anyway, binding to caller's immediate scope doesn't seem that useful since you could just pass it as a parameter when calling.Correct and I completely agree. Chris Stockton wrote:
I am curious if is_callable will be able to detect these?Yes, as is call_user_func able to call them. (But as I was verifying that I saw that there was a tiny bug in the code that makes sure the internal names are not used directly, I will fix that.) Richard Quadling wrote:
Yes, shure, ok, it's not a reference in the classical sense BUT the effect is the same: A change INSIDE the closure changes the variable outside. The only useful way of doing that in PHP without rewriting the complete engine is using references - and such things are *already* done via references - namely global variables: If you import a variable via $global, in reality you are creating a reference to the actual global variable - global $foo is actually more or less the same as $foo =& $_GLOBALS['foo']. Regards, Christian[JS Example]I'm not sure I would say that there is a reference used there. I'm no expert, but x, f() and n are all working like normal variables with x having to look outside of f(). Unless I'm getting confused with "pass by reference".