Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ub.d.umn.edu!cs.umn.edu!sialis!quad!dts From: dts@quad.sialis.mn.org (David T. Sandberg) Newsgroups: comp.lang.c Subject: Re: TRUE and FALSE Message-ID: <585@quad.sialis.mn.org> Date: 1 Sep 90 11:34:17 GMT References: <11215@alice.UUCP> <514@demott.COM> <664@csource.oz.au> Reply-To: dts@quad.sialis.mn.org (David T. Sandberg) Organization: Quadric Systems, Richfield MN Lines: 40 In article <664@csource.oz.au> david@csource.oz.au writes: >Shouldn't > > # define FALSE 0 > # define TRUE (!FALSE) > >_always_ work? Sorry, this is no different than defining TRUE as 1... (!FALSE) is (!0) is (1), after all. My two cents: I define FALSE as 0 and TRUE as 1 on a regular basis, but only use them to make assignments to flag variables more self- documenting. I seldom use the defines for the conditional tests of those variables, and _never_ use them to test the zero or nonzero condition of any function or expression which doesn't explicitly use those same defines in yielding it's result (that means no standard library functions or macros, for starters). When I do need to save the result of such things in a variable being used as a boolean, I do so using the longer (but safer) method: int gotdigit = isdigit(c) ? TRUE : FALSE; (This could be made into a BoolValue() macro if one wished to do so. I haven't.) It seems to me that these defines can be quite helpful and safe if the programmer maintains some level of discipline and restraint in deciding where it is appropriate to use them. In fact, at the restricted level in which they appear in my code, TRUE could be defined as any nonzero value without adversely affecting it's functionality. If changing TRUE's value would break any given expression, then that expression is one which in my opinion should have been considered to be out of the scope of these defines in the first place. -- \\ \ David Sandberg, consultant \\ // "Small hats!" / Richfield MN // \\ \ dts@quad.sialis.mn.org \\