Re: Constant and expression ?

From: Date: Wed, 19 May 2010 12:43:14 +0000
Subject: Re: Constant and expression ?
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-48352@lists.php.net to get a copy of this message
Hi, On Wed, 2010-05-19 at 13:03 +0200, fqqdk wrote: > 2010/5/19 Tjerk Anne Meesters <datibbaw@php.net> > > I wrote a small article that gives an idea of the speed differences: > > http://shwup.blogspot.com/2010/04/about-constants.html Unfortunately this doesn't tell, what you actually measured. And note that as of 5.3 the "class constant" syntax can be used in the global scope, too. > How about extending the usage of the 'final' keyword to support a java-like > syntax? No. We have a const keyword. Rather somebody interested in this topic might try to come up with a patch to at least allow "constant expressions" this should serve most needs. constant expressions might be stuff like __DIR__.'/foobar.php' or CONST_A | CONST_B. We already have two steps in the constant resolution for constructs like these: php > class A { const C = FOOBAR; } php > define('FOOBAR', 42); php > echo A::C; 42 See zval_update_constant_ex in zend_API.c as a starting point. While such an approach would also require some parser work and some clever idea where/how to store the expression to be evaluated etc. johannes

« previous php.internals (#48352) next »