Frank Mori Hess wrote:
Nothing is a problem once you get used to it. I apologize for using a bit of hyperbole, let me try again. I consider the following obvious: given two expressions like "!x" and "x==false" we have:
desirable behavior: they both compile and mean the same thing. neutral behavior: only one compiles. undesirable behavior: they both compile and mean completely different things.
This is obviously a matter of stylistic preference, but still, mine runs contrary to yours. x == false is an anti-pattern and should never be preferred to !x, even when x is bool; similarly, x == true is an anti-pattern and should never be preferred to plain x. Boolean logic doesn't have ==. Nobody prefers ( x == y ) == false to !( x == y ) or x != y, let alone ( x == y ) == true to x == y. And when our original x is not bool but, say, a pointer, x == false is just silly, even though it works.