Am 12.11.2017 um 19:25 schrieb Rowan Collins:
On 12/11/2017 09:49, Fleshgrinder wrote:
There is one thing that differs for the const
and the field: a const value must be known at compile time, whereas a
field value does not. An important difference!

     class A { abstract public const FOO: int; }
     class A { abstract public function foo(): int; }

These also look basically the same. The return value of the method,
however, may also be determined at runtime (just like with fields) and
on top of that might change with every invocation.

What I'm not really clear on is *why* the value being known at compile-time is important to you. Is there some architectural decision you would make differently based on this guarantee? Are you expecting the language itself to have some optimisation or different behaviour based on that guarantee?
compile time at least leaves space for optimization and looking what opcache only since PHP7.0 got and looking forward to a JIT implementation this can make a difference in the future

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to