Re: [RFC] [VOTE] Constant scalar expressions
| From: | Bob Weinand | Date: | Fri, 22 Nov 2013 13:09:50 +0000 |
| Subject: | Re: [RFC] [VOTE] Constant scalar expressions | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70282@lists.php.net to get a copy of this message | ||
Am 22.11.2013 um 10:18 schrieb Yasuo Ohgaki <yohgaki@ohgaki.net>:
> On Fri, Nov 22, 2013 at 2:38 PM, Tjerk Meesters <tjerk.meesters@gmail.com> wrote:
>
>> [yohgaki@dev tmp]$ php bench.php
>>> Time: 6.4104981422424
>>> Time: 7.7053151130676 20.198383060014% slower
>>> Time: 8.022579908371 25.14752723358% slower
>>> Time: 7.5032601356506 17.046444272519% slower
>>> Time: 7.713919878006 20.332612331241% slower
>>>
>>
>> This is way too much variation to be reliable.
>>
>>
>
> VM was working while executing the script :p
>
>
>> Actually, the test should be done against two separate builds:
>> 1) build without patch
>> 2) build with patch
>>
>
> I agree.
>
> Since the script includes loop overhead, pure difference is much larger.
>
> It's a small difference, but people are working remove unnecessary
> memory indirection, etc for better performance.
>
> We might be better to consider extending define().
>
> Regards,
>
> --
> Yasuo Ohgaki
> yohgaki@ohgaki.net
Hi,
I just wanted to note that it also implies default values in function arguments and properties
values upon initialization.
That are things where you need that RFC (without polluting the current namespace with constants).
Compare:
Old:
const a = 10;
define("b", a * 2);
class name {
public static $b = b;
}
With patch:
const a = 10;
class name {
public static $b = a * 2;
}
I think the latter is much cleaner to write. Also the latter should be faster: no extra function
call.
See also: https://wiki.php.net/rfc/const_scalar_exprs#class_property_declarations
(and following two examples)
Bob