Re: PATCH: anonymous functions in PHP
| From: | Wez Furlong | Date: | Tue, 20 Mar 2007 18:40:46 +0000 |
| Subject: | Re: PATCH: anonymous functions in PHP | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-28490@lists.php.net to get a copy of this message | ||
You need the callable type to store the closure information.
Either that, or you need to store it in the op_array, which is "bad" because you don't know when you can free that closure state, so you have to carry it around for the rest of the request.
I agree about $_SCOPES['foo']. I'm actually starting to lean towards just copying the entire local scope hash table and storing it in the callable/closure, and using that to initialize the symtable when you call into the function.
--Wez.
On Mar 20, 2007, at 2:20 PM, Stanislav Malyshev wrote:
How do you know it's 'i'? Does it mean compiler should record any reference to _SCOPES? What if I do $_SCOPES[$foo] - is it that unthinkable? What if I doo $a = "_SCOPES", $$a[$foo]? Only way I see you can really do it is to explicitly declare the imported variables, otherwise you'll lose them - PHP is too dynamic for compiler to be able to statically resolve it. On a side note: why one needs callable type? What can be done with it which can't be done with string and $string()? --Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/of the function. Again, this would be created based on the $_SCOPES fixup information, and again, $_SCOPES['i'] would be rewritten as simply $i in the op_array. So the funcs array might look like this is var_dump()'d: 0 => callable('__anon_0', array('i' => 0)), 1 => callable('__anon_0', array('i' => 1)), 2 => callable('__anon_0', array('i' => 2))