On November 27, 2003 01:38 am, Shachar Shemesh wrote:
While I will be happy to hear Dimi's rational for his, I don't think there is much room for an actual "discussion", as these things tend to turn into religious flame wars.
OK, I'll take the bait. Of course, there is no big difference between them, but I prefer the ! variant simply because it's (1) more terse, and (2) more idiomatic (in C) for testing for 0.
Note that I reached the conclusion that being religious about NULL vs. 0 is just mental masturbation. In fact, I ofter prefer 0 instead of NULL for the same reason as above: it's a lot more terse (like when calling a function that takes 10 args, 9 out of which must be 0).
There are some things that are _absolutely_ fundamental to the language, and one of them is that NULL is 0. The 'NULL' abstraction is paper thin, and it simply doesn't give you anything. Can you change the definition of NULL to, say, 1 on some architecture without breaking stuff left right and center? No. So then what is its purpose, other than some sort of warm and fuzzy feeling of doing the 'right' thing? It just shows that we don't understand that in C values are either zero or non-zero, and that is the first stone at the foundation of the language, and you simply can not change that.
Same holds true for booleans. I see no purpose whatsoever in pretending that boolean operators are only for BOOL. They are perfectly fine for figuring if a value is zero or not, anything else is politics ;).