Hello,
Reading the prior discussion, I think either $_SCOPE['x'] or the
lexical $x syntax is fine for accessing local variables in the
enclosing scope. But closures also should also support $this and
static:: when the closure is defined in a method.
I think a solution for closures should add a new variable type. That
way, the code can compiled at compile time, while the enclosing
context (local variables plus $this for methods) can be captured at
run time in the new variable type. Also, when the closure value is
garbage collected, the references to the enclosing scope and object
instance can also be freed.
Additionally, the callback psuedo-type could be promoted to the new
type, with the string or array representation converted when
required. It wouldn't be necessary, but a callback literal along the
lines of Array() could also be added to make the conversion
unnecessary. I find the following to be easier to understand:
set_error_handler(Callback("foo"));
Than
set_error_handler("foo");
The current syntax would still work because of automatic type
conversion.
Best Regards,
Jeff
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php