RE: [PHP-DEV] [RFC] Constant Scalar Expressions

From: Date: Wed, 14 Aug 2013 14:48:09 +0000
Subject: RE: [PHP-DEV] [RFC] Constant Scalar Expressions
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-68519@lists.php.net to get a copy of this message
On Wed, 2013-08-14 at 12:03 +0100, Derick Rethans wrote: > On Wed, 14 Aug 2013, Patrick Schaaf wrote: > > > Would this allow using constants, too? Class constants? > > > > const FOO = 1; > > const BAR = self::FOO + 1; > > const BAZ = self::FOO + 2; > > const BARF = GLOBAL_BARF; > > const IMPORT = otherclass::IMPORT; // with autoloading? > > > > In my opinion these would start to make the feature useful. > > Those are not constants, but expressions which can't be run during > compile time. We already support constants where we calculate the value at runtime via ZEND_DECLARE_CONST opcode. i.e. class A { const C1 = 1; const C2 = A::C1; } is valid. If we allow scalar arithmetic we should extend this, too to be consistent in the language. johannes

« previous php.internals (#68519) next »