Hi! > The constant expressions will be evaluated at the same time php currently > evaluates constant > expressions.
But you essentially propose running arbitrary code at that time, which is much bigger deal than evaluating simple constant expressions. While simple functions like strlen() would probably be OK, running arbitrary function means possibility for arbitrary side effects, which makes the whole thing completely unpredictable. > Another problem with using define() is that opcache cannot optimize global > constants, opcache can't also optimize runtime-evaluated constants, because results and side-effects of an arbitrary function call is not guaranteed to be the same. It could only optimize anything if it were guaranteed that the function is pure, does not depend on anything but its arguments and has no side effects. > because define() will emit a notice instead of raising an Error if the > constant already exists. You can trivially check for this, and if it ever would be a problem, define() error level can be changed, but I don't think it's a real issue since it was never changed so far. > So the performance is slightly worse. If you try to optimize performance this way, you're optimizing performance in a wrong way. No sane code would depend on performance of define(). -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php