TRUE and FALSE

Sean Legassick asrap at warwick.ac.uk
Thu Aug 30 01:39:17 AEST 1990


In article <2316 at cirrusl.UUCP> dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
=In <514 at demott.COM> kdq at demott.COM (Kevin D. Quitt) writes:
=
=     TRUE and FALSE are used for assignment purposes only.  It makes
=     the intent of the code more obvious.
=
=When I find somebody who really, really, really wants to define TRUE
=and FALSE, even somebody who uses them for assignment only, I recommend
=the following defines instead:
=
=     #define ZERO   0
=     #define ONE    1
=
=These are so much more clear than TRUE and FALSE, and if you use
=them in a test, you know exactly what you're testing!

	This has to be one of the most useless suggestions I have read on
this newsgroup. How about some more defines:

	#define TWO 2
	#define THREE 3
	#define FOUR 4
	....
	#define NINE 9

	And how about some more:

	#define EQUALS ==
	#define LESSTHAN <	...... ad infinitum

	Okay, so maybe I'm going over the top a little - but you get my point.
Personally I go further than simply using TRUE and FALSE (which by the way
I always define as (1==1) and (1==0), not for portability but for a little
extra clarity and any compiler worth its salt will optimise them down anyway).
	I have in a standard header file a typedef for bool (which I typedef
to an int, although if I used ANSI extensions I could add even more clarity
and typedef to an enum { false, true }. This I find is invaluable for
clarities sake. An int declaration says to me this variable is going to hold
a scalar value - which is very different from a boolean one.
	I would be interested in anyone who thinks an int declaration of
a boolean variable is clearer. The only argument against my method I can think
of is that of standardisation - bool isn't a standard C type and shouldn't
be as it is still basically an int. However of all the additional types
I have seen in people's source, bool is the one I've seen most often.

---------------------------------------------------------------------------
Sean Legassick,       cuuee at uk.ac.warwick.cu  "Improbability factor of one
Computing Services    asrap at uk.ac.warwick.cu    to one. We have normality.
University of Warwick      	 	         Anything you still can't
            (the walking C obfuscator!)	 	  handle is your own problem."



More information about the Comp.lang.c mailing list