Re: Why can constants only be scalars?

From: Date: Sat, 08 May 2004 19:39:46 +0000
Subject: Re: Why can constants only be scalars?
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-9739@lists.php.net to get a copy of this message
On Sat, 2004-05-08 at 12:35, Sara Golemon wrote: > > > 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. > > > > Whoa... easy, don't go putting words in my mouth... > > I never said I wanted constants to allow arrays/objects, just wanted to > understand the reasoning which Andi explained well. I also had an a-ha > moment over breakfast: A constant array would require the allowance of > syntax like echo FOO[0]; which is, for my part, ugly. The problem I see with the "ugly argument" is that if non-scalars were allowed for constants then YOU (and I and everyone else) would have the option of opting out of using constants for non-scalars (and subsequently the above "ugly" syntax). Personally I don't see anything ugly or wrong with using the above syntax. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.internals (#9739) next »