On 7 Sep 2014, at 13:22, Sherif Ramadan <theanomaly...@gmail.com> wrote:
> I've played around with this branch for a bit and seems reasonable, passes > the tests, and doesn't seem to have any serious issues/memories leaks > AFAICT. There’s actually a quite serious issue just now, which is that it evaluates the first operand twice if it’s not empty. This is because $a ?: $b is expanded to empty($a) ? $b : $a, such that if you did something which mutates state in there, it’d happen twice. This is obviously not good, and I’m going to figure out how to fix this. > I can't stress enough, however, how important it is for us to avoid > inconsistencies in behavior between various forms of syntax. This is often > something users complain of as often they complain about not getting such > features. So let's make ternary consistent before we implement yet another > oddity in PHP (half-assed and ill designed). > > I don't actually agree with the premise that ternary should wrap the first > operand in empty() to begin with, but if this is what people want, fine. > Let's just do it right. > > And as Rasmus mentioned in the PR, make the documentation very _cleary_ if > it gets accepted. Yeah, I’ll be sure to make it crystal clear that they aren’t quite the same. FWIW, it’s not our only shorthand which differs in behaviour. For example, ++ and += 1 are NOT the same, though I’d love to fix that particular inconsistency. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php