note 39672 deleted from language.operators.logical by colder
| From: | colder@php.net | Date: | Fri, 20 Apr 2007 15:39:19 +0000 |
| Subject: | note 39672 deleted from language.operators.logical by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125700@lists.php.net to get a copy of this message | ||
Note Submitter: kws_ at hotpop dot com
----
"Just Because You Can, Doesn't Mean You Should."
I also feel that circumventing short-circuit evaluation and relying on side-effects in conditional
expressions is exercising bad style. Writing code that documents itself using clear and
straightforward constructs strikes me as a much better practice than using a convoluted and
difficult-to-read expression and explaining it with comments (or worse yet, not documenting it at
all!) Indeed, source code should be written for the programmer's eyes more so than the
computer's.
Utilizing the bitwise operators in a logical context could violates the expectations of the reader
and may create confusion because bitwise operators imply bit-field operands.
I also feel that assuming that short-circuit evaluation is best for logical constructs IS within the
compiler's "rights", since when logical operators are used for their intended
purpose, the assumptions that short-circuiting makes *ARE* logical, and do (once again, when used
correctly) optimize evaluation of logical expressions.
It is not my intention to directly flame or insult any individual, but only to discourage the use of
poor style and to encourage new (and even some experienced) programmers to write clear and verbose
code, and to think about the programmers, rather than the computers that might end up trying to
decipher your creations.