Richard Lynch schreef:
Is there any reason why the logic behind define() couldn't be pushed down to
class const?
probably no reason why it couldn't but from what I gather there is a specific
reason wht it works like this: speed.
const is compile time, define is runtime
IIRC const was made this way in order to make it fast.
I also recall posts by Matt Wilmas on internals regarding a patch for 'constant
expression
folding' which allows simple expressions in const definitions (whilst keeping
the compile
time speed) ... I think it made it in to 5.3 but you'd have to check.
Code like this is kinda fugly:
//It's okay here, but not in a class?
define('CACHE_DIR_LONG', CONFIG_ROOT_PATH . '/cache/');
class Cache {
const CACHE_DIR = '/dev/shm/cache/';
const CACHE_TTL = 300; //5 minutes
const CACHE_DIR_LONG = CACHE_DIR_LONG;
I'd really prefer to write:
class Cache {
const CACHE_DIR = '/dev/shm/cache/';
const CACHE_TTL = 300; //5 minutes
const CACHE_DIR_LONG = CONFIG_ROOT_PATH . '/cache/';
talking of fugly, your declaring a class, from a purists POV it really
shouldn't contain such values in it's definition ... these are things
you set when initializing the class/object for use. :-P
I'm happy to add it as a feature request, but not if somebody reliable says "Don't
Bother"...
I'd go with "Don't Bother" ... although check the internals archives
as your desired feature may actually be on it's way in, in some form.
--
Richard Lynch
_______________________________________________________
The information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial use of the individual or entity to which it is
addressed and may contain information that is propri-
etary and confidential. If you are not the intended
recipient of this message you are hereby notified that
any review, dissemination, distribution or copying of
this message is strictly prohibited. This communica-
tion is for information purposes only and should not
be regarded as an offer to sell or as a solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be secure or error-
free. P6070214
bla bla bla.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php