Re: [RFC] [VOTE] Constant scalar expressions

From: Date: Fri, 22 Nov 2013 01:19:17 +0000
Subject: Re: [RFC] [VOTE] Constant scalar expressions
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-70272@lists.php.net to get a copy of this message
Hi all, On Fri, Nov 22, 2013 at 10:09 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > Anyway, constant variables are useful for VM/op code optimization. > > include('foo.php'); // const a = 123; > const b = a; > > is allowed currently. We may restrict this behavior only to the same file, > so that VM/op code optimization can be done. > > Currently, no expression is allowed with 'const'. Defining 'const' using > another constant with the same value is useless. It's a bad coding > practice > in many case, I suppose. > > I understand use cases of scalar expressions with constants, but I'm > concerned > loosing door for further optimizations. (e.g. $x = $x + 123 is faster than > $x = $x + a, > where a is 123 in constant var hash) > > We may be better to restrict expressions with constants only to the same > file > even if we loose some benefits/flexibility in user code. > > Is this discussed? > I voted 'yes', but I change my mind. Sorry. If the RFC leaves door for constant optimization, I'll vote 'yes'. Constant look up is not a simple hash look up. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#70272) next »