Re: [RFC] [VOTE] Constant scalar expressions

From: Date: Wed, 20 Nov 2013 21:11:31 +0000
Subject: Re: [RFC] [VOTE] Constant scalar expressions
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-70248@lists.php.net to get a copy of this message
Am 20.11.2013 um 21:55 schrieb Yasuo Ohgaki <yohgaki@ohgaki.net>: > Hi Bob, > > On Thu, Nov 21, 2013 at 5:17 AM, Bob Weinand <bobwei9@hotmail.com> wrote: > As noted in the RFC "The patch is ready to be merged. (Opcache support is included, thanks > to Dmitry)". > > So, Dmitry already did the patch for opcache and I assume he has done the best possible for > that. > > Btw. opcache doesn't affect constants if I'm not wrong, because, what would you > optimize here (already possible): > > a.php: > if ($argv[1] == "include") > include 'b.php'; > const B = A; > > b.php: > const A = 10; > > Here we can't cache anything because the constant B depends on a conditional inclusion: > same problem. > > It's that same way resolved with the current patch. > > Also constant expressions (like 2+2 without constants involved) are resolved at compile time. > > So I can't detect any impact related to opcache. > > I thought whole point of introducing "const" while we have define() was to make > constant cachable in ops. > > Anyway, I'll vote 'yes' in that case. > > Thank you. > > BTW, any reason why there is no constant array? > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net Hi, That'd just be outside of this RFC's scope: const ABC = [1, 2]; is currently not allowed. Also you can't write ABC[0]. That'd be a whole other RFC to add array support for constants. So we could enable it for (static) properties, but why should we? Additions of arrays would be the only valid operation, but can you imagine _any_ use case where we'd need that when the only dynamic operands (constants) can't be arrays? Bob

« previous php.internals (#70248) next »