Re: Why can constants only be scalars?

From: Date: Sun, 09 May 2004 04:09:00 +0000
Subject: Re: Why can constants only be scalars?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-9740@lists.php.net to get a copy of this message
--- Robert Cummings <robert@interjinn.com> wrote: > 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. Agreed. "ugly" is a subjective argument and does not change the usefulness of that particular ability. Where would the C language be without the ability to define arbitrary constant values? - Gabriel =====

« previous php.internals (#9740) next »