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:

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))

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
[EMAIL PROTECTED]  http://www.zend.com/


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Reply via email to