--- Robert Cummings <[EMAIL PROTECTED]> wrote: > On Sat, 2004-05-08 at 03:19, Andi Gutmans wrote: > > 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. > > I always thought constants were about imposing an > unchanging nature to > the data and not about visual aesthetics when > reading code :/ I too > would like to see constant support of non-scalar > values.
Same here. I have a number of static arrays that I use for reference data that are usually encapsulated in a function, or a global / session variable. It would be very handy to be able to define a constant array instead. - Gabriel ===== -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php