TRUE and FALSE

Rahul Dhesi dhesi%cirrusl at oliveb.ATC.olivetti.com
Fri Aug 31 11:47:12 AEST 1990


I was brash enough to suggest

     #define ZERO   0
     #define ONE    1

and Sean Legassick chastises me thus:

     This has to be one of the most useless suggestions I have read on
     this newsgroup.

But in fact my suggested definitions are much more useful than the
common recommendation of defining TRUE and FALSE.

No matter how careful the original programmer is, sooner or later
somebody will come along and, noticing that TRUE means true, will try
to do something like:

     i = isdigit(c);
     ...
     if (i == TRUE) ...

thereby introducing a bug.  If, on the other hand, TRUE were not defined
but ONE were available, the coder would probably do:

     i = isdigit(c);
     ...
     if (i == ONE) ...

which would immediately make him ask himself:  "The return value from
isascii() is true, but is it really 1?"

Of course, defining ONE and ZERO is fairly silly.  But defining TRUE
and FALSE is quite risky.  I'll take fairly silly over quite risky any
day.
--
Rahul Dhesi <dhesi%cirrusl at oliveb.ATC.olivetti.com>
UUCP:  oliveb!cirrusl!dhesi



More information about the Comp.lang.c mailing list