Re: PATCH: anonymous functions in PHP

From: Date: Tue, 20 Mar 2007 18:20:26 +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  Groups: php.internals 
Request: Send a blank email to internals+get-28488@lists.php.net to get a copy of this message
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 stas@zend.com http://www.zend.com/

« previous php.internals (#28488) next »