Re: Operator precedence is undefined?

From: Date: Sat, 20 Jul 2013 04:28:25 +0000
Subject: Re: Operator precedence is undefined?
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-68250@lists.php.net to get a copy of this message
Hi Sara, 2013/7/20 Sara Golemon <pollita@php.net> > On Fri, Jul 19, 2013 at 7:16 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > >> >> >> If there aren't comments, I'll rewrite the example. >> >> >> There were comments. I explicitly told you that that the behavior is > defined as undefined. You CHOSE to ignore that comment. You CHOSE to > break the documentation. > If there is defined precedence, arithmetic operation should follow it. If there is exception, it should be documented. I don't understand why/how the arithmetic operation can be ambiguous with defined precedence. (++ and -- are higher than +) $a = 1; echo ++$a + $a++; should always print 4 with current PHP precedence definition. If it does not, it's a bug in language. // mixing ++ and + produces undefined behavior $a = 1; echo ++$a + $a++; // may print 4 or 5 I don't see any reason it became undefined. If this kind of simple precedence is broken, how programmers write code and/or trust the language? http://3v4l.org/mR4da/vld#tabs This site seems support PHP 4.3.0 to PHP 5.5.0 and opcode looks fine. Am I missing something? If you would like to suggest use of (), it should be done differently. IMHO. The comment only ruins PHP's reputation as language. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#68250) next »