Re: [RFC] Constant Scalar Expressions (with constants)

From: Date: Thu, 07 Nov 2013 12:41:55 +0000
Subject: Re: [RFC] Constant Scalar Expressions (with constants)
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-70050@lists.php.net to get a copy of this message
On Thu, Nov 7, 2013 at 1:31 PM, Lars Strojny <lars@strojny.net> wrote: > Hi Bob, > > thanks for your work, it’s awesome. One thing about constants: > > Take this example: > > const FOO = 2; > > class Klass > { > const FOO = 1; > const BAR = FOO; > } > > Here FOO is ambiguous, as it could resolve to 2 or to 1. If I understood > it correctly, global constants are not yet implemented but I would suggest > to always force prefixing the constant to get rid of the ambiguity and > allow for future extension. > > const FOO = 2; > > class Klass > { > const FOO = 1; > const BAR = self::FOO; > } > > Does that make sense? > The code snippets you posted are *already* supported (e.g. in PHP 5.5). FOO will resolve to the globals constant, self::FOO to the class constant. Presumably the extended support in static expressions will retain those semantics :) Nikita

« previous php.internals (#70050) next »