Hi!
Correct me if I'm wrong, but given the fact that PHP only* supports functions defined in the global space**, with the additional ability to import global variables using the global statement, wouldn't that make named functions able to close-over global variables?
It's different mechanism. Globals are just references to variables in same global scope, they are not bound to any function, etc.
And, if the above is true, wouldn't it be consistent to support the use statement on named functions, and then deprecate the global statement?
That's why I'm not a big fan of that "consistency" argument here on the list - because it usually means "let's implement some feature because I like it", but not more. Which is fine, but it has nothing to do with consistency. Particularly, scope capturing and all that has very little relation to what globals do. Closures carry around "captured" variables. Regular functions don't. Global scope exists independently of them. The mechanism is similar (well, it's the same engine, how many there can be? :) but they are not the same.
** namespaced functions don't make any difference, as variables aren't namespaced.
I'm not sure what you mean here, as variables in PHP are scoped. Global functions are not scoped, of course, but can be namespaced.
-- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zend.com/ (408)253-8829 MSN: s...@zend.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php