Lawrence said:
Not for you perhaps, but for some people certainly. Overall that makes it
less readable.
Those two sentences are contradictory.
[...] The trick in question is not general, using it can give you a false
sense of security.
Its generality is not relevant. Its primary use is in catching a lot
of low hanging fruit, which is all you can expect a "saftey convention"
to do anyways. The claim about "false sense of security" is not
credible, and just an assertion that you have no way in hell of backing
up.
If one is using practices such as constant-first comparisons,
commenting switch drop-throughs, testing with maximum compiler warnings
on multiple compilers, running your code through lint and using
semantically reflecting naming conventions then one is more likely to
be alert to safety problems, not assuming a sense of safety that isn't
there.
By *itself* it is an insufficient measure for maximal safety, but using
it does not imply that you not using other mechanisms. That would be
Richard Bos-logic.
[...] Most compilers and failing that checking tools such as lints can
check for this much more reliably, WITHOUT the need to formulate the
code in a less natural way.
If you are compiling to one compiler that specifically covers this,
then that might work for you. But I, personally, have not encountered
one single compiler anywhere that satisfactorily issues all the
warnings I would like it to. So even in the best of circumstances I am
basically giving up some warnings anyways, and == vs = testing in
control code is one of those warnings.