On 10/27/2017 11:15 PM, Nikita Popov wrote:
> PHP does not permit self-referencing constants.
> 
> However, this is only checked when the constant is first accessed. In your
> first example the constant is never accessed, so no error is thrown. This
> has nothing to do with subclasses defining the value -- you're using late
> static binding, so you're accessing the constant of the child class
> directly.
> 
> PHP cannot detect self-referencing constants during compilation, because
> they may be formed through non-trivial cycles involving multiple constants,
> across multiple files.
> 
> Nikita
> 

My wording was maybe a bit wrong here, and I was biased by the fact that
I would like to see abstract constants. The fact that not everything can
be detected at compile time, but only later at runtime is normal in a
highly dynamic language like PHP. Self-referencing constants make no
sense, hence, it is fine. It would of course be better if the compiler
could detect that earlier, but we are not doing AOT so imho that is
fine. The behavior here is also consistent among versions as well as
HHVM, all good.

What do you think about the other ideas I raised?

-- 
Richard "Fleshgrinder" Fussenegger

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to