Re: Operator precedence is undefined?

From: Date: Sat, 20 Jul 2013 03:09:51 +0000
Subject: Re: Operator precedence is undefined?
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-68239@lists.php.net to get a copy of this message
On Fri, Jul 19, 2013 at 10:36 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > Hi Sheif, > > 2013/7/20 Sherif Ramadan <theanomaly.is@gmail.com> > >> Then I would say that example is wrong, but people may find reason to >> disagree. I'm basing my contention purely off what I see in php-src and the >> documented behavior for those operators. To me I see no reason why this >> behavior would be considered undefined. The ternary operator definitely has >> some undefined behavior in terms of precedence since its interpreted as a >> statement and not like other operators in expressions. To me post/pre >> inc/dec are pretty well-defined. >> > > I wasn't going to document ambiguity, but ?: > operator's association difference between C and PHP. > It's a common pitfall for C programmers when they use nested ternary > operators. > Yea, I believe the documentation at php.net/ternary already advices against nesting ternary in PHP. Honestly, I don't know how you would even put ternary into the precedence table given that it reads more like a statement and less like an operator. Just look at the implementation in the parser and you will be left in wonderment.

« previous php.internals (#68239) next »