note 34746 deleted from language.operators.comparison by didou
| From: | didou@php.net | Date: | Tue, 05 Aug 2003 19:04:32 +0000 |
| Subject: | note 34746 deleted from language.operators.comparison by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-53445@lists.php.net to get a copy of this message | ||
Note Submitter: bishop
----
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/)