I've been wanting a true first-class callable type for a while.
-Andrei
On Mar 19, 2007, at 5:02 PM, Wez Furlong wrote:
The second possibility would be to make a first-class callable zval
type which stores that information in the return value from the
function declaration. The callable type would store a pointer to the
op_array as well as a hash table to use to initialize the local scope
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))
Adding a type seems cleaner, but obviously requires more work as the
rest of the internals need to understand what to do with it.
A third possibility is similar to the second, but a bit less invasive.
Create a callable class type to encapsulate that information. The
rest of the internals would see $funcs[0] as an object, but the engine
would know that calling it will invoke the appropriate function,
prepping the local scope as described above.
--Wez.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php