On Thu, 2013-08-15 at 16:42 -0700, Stas Malyshev wrote: > Hi! > > > Though obv, in reality we wouldn't use runkit_constant_add(), it'd be a > > new opcode which had the same effect. This is basically transparent to > > opcode caches, allows the constant to actually change based on runtime > > If the class definition can actually change at runtime, I think it'd > make it much harder for opcode caches since they can't any longer assume > class definition can't change at any random place in the code. > > But this is not the most tricky part. The most tricky part is this: > > > if(true) return; > class Foo { > const halfpie = M_PI/2; > } > > Now what happens if this is implemented as an opcode? We can't run any > opcodes past return statement, but Foo is expected to be defined here.
note that we have this functionality already: $ php -r 'class A { const C = FOO; } define("FOO", 23); echo A::C;' 23 The first fetch will resolve that. If we add "constant scalar expression" this has to work for class constants, too. Else we add crazy new inconsistencies to the language. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php