Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!ukc!warwick!asrap From: asrap@warwick.ac.uk (Sean Legassick) Newsgroups: comp.lang.c Subject: Re: TRUE and FALSE Message-ID: <1990Aug29.153917.28110@warwick.ac.uk> Date: 29 Aug 90 15:39:17 GMT References: <11215@alice.UUCP> <514@demott.COM> <2316@cirrusl.UUCP> Sender: news@warwick.ac.uk (Network news) Organization: University of Warwick, UK Lines: 50 In article <2316@cirrusl.UUCP> dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) writes: =In <514@demott.COM> kdq@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@uk.ac.warwick.cu "Improbability factor of one Computing Services asrap@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."