note 34746 added to language.operators.comparison

From: Date: Tue, 05 Aug 2003 17:55:46 +0000
Subject: note 34746 added to language.operators.comparison
Groups: php.notes 
Request: Send a blank email to php-notes+get-53441@lists.php.net to get a copy of this message
Clarification to what my original comment on which dragon_rage4 at hotmail dot com followed: Without testing, you don't know a priori whether a parser will look at expressions left to right or right to left. Statements such as: 1. $i == $i++ OR 2. $i == ++$i are not only hard to mentally understand, but also subject to side effects which you may or may not expect. If the parser (in PHP's case) moves left to right, case #1 is true, and case #2 is false. If it moves right to left, case #1 is FALSE, and case #2 is false. If your native language reads left to right, you expect left to right evaluation, and -- as PHP is English-oriented -- you can expect (as dragon's experiments show) left-to-right evaluation. Because the Zend engine is the same regardless of the plaform, PHP code will continue to evaluate left to right. In C, where you have 6 billion compilers, this isn't always guaranteed -- not everyone implements compilers in the same way. So my point is don't write something tricky (like the above) because: 1. It's hard to understand on inspection 2. One day in the future the Zend engine might start evaluating right to left and your code will fail. (now on: Project Pitchfork - Carnival - Covenant Remix boston.electro.industrial.culture @ http://www.angeldustrial.com/v2/) ---- Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34746 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34746&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34746&report=yes

« previous php.notes (#53441) next »