Hi!

const foo = function () use ($globalVar) {

};

How would you call this thing? foo()? Then you have a problem - foo() already has meaning, and it's "call function named foo", not "get constant named foo and call function inside if it's there". Also, it would work different from variables: for variables, these both work:

$foo1 = "foo"; $foo1();
$foo1 = function() {}; $foo1();

But for constants the first form wouldn't work - unless you also make foo() mean "check constant foo and if it's a string then call function with the name that equals to its value" - which adds a lot of complexity there.

Also note, that const expressions can be used in defaults now (properties, parameters, etc.) - and that means they are cacheable. But Closures aren't cacheable and couldn't be used in defaults - that means you'd be introducing two types of const expressions - the "real const" and the "as if" const.
I do not see it working.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

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

Reply via email to