Hi Tim

> Using Alain's example of static variables that depend on each other. For
> the following:
>
> function foo() {
>    static $a = 0;
>    static $b = $a + 1;
> }
>
> The value of '$a' is known at compile time. Is the value of '$b' also
> known at compile time? It might make sense to include that as an
> explicit example in the RFC (examples are cheap).

Interesting thought. $a's initial value is known at compile time, but
$b's isn't because it doesn't depend on $a's runtime value by the time
it reaches $b's initialization. This value could change between $a and
$b's initialization through direct assignment, by-ref modification, or
even access by-name which is not easily detectable. I've added a
section to the RFC to explain how this works in more detail.

https://wiki.php.net/rfc/arbitrary_static_variable_initializers#what_initializers_are_known_at_compile-time

Let me know if anything is still unclear.


Ilija

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

Reply via email to