Hi, Just asking: Does this cover only declarations, or every constant expression, for example
$weeks = $secs / (60 * 60 * 24 * 7); becomes to the opcode-equivalent of $weeks = $secs / (604800); ? 2013/8/14 Anthony Ferrara <ircmax...@gmail.com> > Stas, > > > On Wed, Aug 14, 2013 at 5:01 AM, Stas Malyshev <smalys...@sugarcrm.com > >wrote: > > > Hi! > > > > >> https://wiki.php.net/rfc/const_scalar_expressions > > > > I like the idea, but absence of constant support makes this thing much > > less useful, as you can't do things like: > > > > public $angle = M_PI/2; > > > > I think this is one of the reasons this idea was never implemented - > > because without constant support you're limited to doing things that are > > quite obvious and trivial. > > > > Yeah, having constants in those expressions would be great. If only > constants in PHP were actually constant... > > But this win is really cheap (a trivial change to the parser), so I figured > it was worth proposing separately. If we want to add the opcode stream > later to do expressions for constant values, we can. This just gives us the > quick win today of allowing relatively trivial, but important expressions. > > The biggest wins I see are in power-of-2 math: > > class Foo { > const FLAG_1 = 1 << 0; > const FLAG_2 = 1 << 1; > const FLAG_3 = 1 << 2; > const FLAG_4 = 1 << 3; > const FLAG_5 = 1 << 4; > const FLAG_6 = 1 << 5; > const FLAG_7 = 1 << 6; > } > > And in other complex formulas where having the self-declaration adds > semantic meaning. > > Now, as far as if it's worth while making the change without constant > support, that's for each of us to decide. I think it is, but if you don't, > that's cool too. > > Thanks > > Anthony > -- github.com/KingCrunch