RE: [PHP-DEV] Constants in namesapces

From: Date: Mon, 27 Aug 2007 05:39:44 +0000
Subject: RE: [PHP-DEV] Constants in namesapces
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-31924@lists.php.net to get a copy of this message
We already have class constant that use declarative syntax and of course define() inside of class doesn't declare class constant. The same was done for namespaces. Thanks. Dmitry. > -----Original Message----- > From: Richard Lynch [mailto:ceo@l-i-e.com] > Sent: Sunday, August 26, 2007 7:50 AM > To: Dmitry Stogov > Cc: 'PHP Internals List' > Subject: RE: [PHP-DEV] Constants in namesapces > > > On Wed, August 22, 2007 8:03 am, Dmitry Stogov wrote: > > You can have "const" outside namespaces but they are not real > > compile-time constants. > > They are set during execution in the same way as define() does. > > > > <?php > > const DIR = dirname(__FILE__); > > echo DIR; > > ?> > > You do realize this is going to engender a few zillion > threads on PHP-General benchmarking the two and endless > arguments about which is faster/better... > > <?php > const DIR = dirname(__FILE__); > define(DIR, dirname(__FILE__); > ?> > > I personally find it kinda silly to have TWO syntaxes for > defining constants in the global space, one of which looks > like a declarative statement in C, which will lead to a whole > new swath of arguments about what is "better" > > Why is 'define' any different than 'class' or 'function'? > > Seems to me that if you want these namespace thingies that > badly, then 'define' should follow the same rules as any > other declarative keyword. > > If you 'define' something in the namespace, it's in the namespace. > > If you want global scope, 'define' it outside a namespace and > be done with it. > > Seems to me you're just complicating things with no > real-world need here... > > What are your real-world "I need this because..." code samples? > > -- > Some people have a "gift" link here. > Know what I want? > I want you to buy a CD from some indie artist. > http://cdbaby.com/browse/from/lynch > Yeah, I get a buck. So? > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.internals (#31924) next »