At 09:16 PM 5/7/2004 -0700, Sara Golemon wrote:
Long ago I was told constants could only be scalars, so I accepted it.
Certainly ZEND_FUNCTION(define) does the check to ensure it's a scalar, but
why?

For what I can tell a zend_constant is just a container for an ordinary zval
which is refcounted and all that fun stuff.  I don't see any obvious reason
for this restriction, and my tests with those restrictions removed seem safe
enough so far...  Can someone spell it out for me with little words?

I don't remember all of the reasons, but the main reason is that it just makes sense (IMO). I think constant values should be easily seen when reading through source code. Having to read logic to see what values are in the constants doesn't make much sense to me. I'd use variables for that.
If we start talking about class constants then it's obviously even more important for them to be constants. You can't evaluate values during the class definition as you don't have variables defined yet. I wouldn't want define() to behave different from const.


Andi

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



Reply via email to