Re: Wired constant expression syntax and bug

From: Date: Mon, 30 Jun 2014 21:27:55 +0000
Subject: Re: Wired constant expression syntax and bug
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-75155@lists.php.net to get a copy of this message
That wasn't in the RFC because there still was the IS_CONSTANT_ARRAY I removed only months later (and replaced with AST) to fix some bugs. It's only at that moment where I now could add that syntax. Bob Am 30.6.2014 um 23:05 schrieb Andrea Faulds <ajf@ajf.me>: > On 30 Jun 2014, at 20:06, Dmitry Stogov <dmitry@zend.com> wrote: > >> Hi Bob, >> >> I'm wondered why you introduced this wired syntax in PHP-5.6. > > Do you mean weird? > >> >> class FooBar { >> const bar = ["bar" => 3]["bar"]; >> } >> >> It wasn't a part of RFC, it wasn't covered by tests, and it actually >> doesn't make a lot of sense. May be it's better to remove it? > > I disagree, it makes perfect sense: > > class FooBar { > const FOO = 3; > const BAR = [ > 3 => ‘qux’, > 4 => ‘bang’, > 7 => ‘theta’, > 9 => ‘epsilon’ > ][FOO]; > } > > ?: and ? only work when there are just two possibilities. > > It is surprising that it wasn’t in the RFC though, I suspect that was just an oversight on > Bob’s part. > -- > Andrea Faulds > http://ajf.me/

« previous php.internals (#75155) next »