News for hackers. Stuff that matters.
Re:What If I Don't Actually Like My Users? (2008) by MaulingMonkey on Friday June 03, 2016 @07:07AM (#11829567)
I always go with strcmp(...) == 0 instead of !strcmp(...).

This better reinforces my mental model of it (like many comparison functions) having 3 possible return values: <0, =0, or >0. !strcmp(...) may be terser, but it is illogical in that logical not isn't an operator. I dig using it on booleans, or "booleanish" values (null vs non-null pointers), but this conceptual tri-state isn't even "booleanish". But C didn't have a proper bool type for awhile, and C++ inherited it's baggage, so they'll compile it.

Meanwhile C# doesn't even think my "booleanish" tests are logical enough to allow to compile - no null reference tests with "operator!" for me.

There are no comments on this comment yet.