TRUE and FALSE (or true and false)

Flint Pellett flint at gistdev.gist.com
Tue Sep 4 07:22:58 AEST 1990



I've received mail from a couple people flaming me for not
reading/knowing that C evaluates booleans to 0/1, when I commented
that using the named constants ZERO/ONE for boolean values was a bad
idea.  They missed my point.   I apparently also missed Rahul's point/
sarcasm-- sorry.

The fact that C evaluates booleans to 0 or 1 and always will has very
little to do with what I said in my posting.  They have assumed that a
boolean is only useful to be evaluated by C, and that is NOT true. 
(As has been demonstrated in other notes here, using it for purposes
other than assigning vars from it is generally not good.)  It is quite
possible that a program is written which contains variables used to
tell a TRUE/FALSE result, where none of those variables are ever used
in a comparison within the program itself.  For example, those truth
values may only be stored away in some database that is read by a
different program.  If the different program is C right now, you'll
define TRUE=1 and FALSE=0.  Next year, you may rewrite the different
program in some other language where TRUE is 0, and FALSE is 1, (maybe
because some contract requires a certain language for some parts of
the system), change the database structure, and you would then have to
redefine the constants in your C program.  Having a "#define ONE 0" in
my code is not something I would want. 

(This also has nothing to do with the argument about how good/bad it
is to have TRUE/FALSE defined because they can be misused by ignorant
programmers.  __Properly used__, a simple and easy to compile 0/1 set
of constants works.) 
-- 
Flint Pellett, Global Information Systems Technology, Inc.
1800 Woodfield Drive, Savoy, IL  61874     (217) 352-1165
uunet!gistdev!flint or flint at gistdev.gist.com



More information about the Comp.lang.c mailing list