Tom Lane <[EMAIL PROTECTED]> writes: > if (ptr) > > Can anyone mount a good readability argument for one over the other?
My argument in favour of "if (ptr)" as well as "if (integer)" and "if (!ptr)" is simply that all else being equal the shorter expression is clearer. Forcing the reader to slog through additional syntax to read the code has a cost. Obviously that argument is subject to abuse and it's very dependent on whether you consider all else equal. For a reduction argument, pretending there's a boolean type with no casts leads to the excessively verbose java-ish syntax like: if (foo != 0 && bar != null && baz != 0) which you can't tell me is easier to read than if (foo && bar && baz) What I miss most in both C and Java is the lispish ability to write expressions like: foo = bar() || baz() || qux(); instead you have to write out things like this (except worse since you have to start storing things in temporary variables): if (bar() != null) { foo = bar(); } else if (baz() != 0) { foo = baz() } else { foo = qux(); } I've seen code that consists of a dozen or so of these things repeated. When the code starts getting so verbose that what could be 12 very simple and clear lines no longer fits on the screen because you're trying to make it easier to understand, well, I think you've lost the battle. -- greg ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly