Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!apple!uokmax!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: TRUE and FALSE Message-ID: <3686@goanna.cs.rmit.oz.au> Date: 5 Sep 90 06:09:05 GMT References: <5398@harrier.ukc.ac.uk> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 31 In article <5398@harrier.ukc.ac.uk>, mtr@ukc.ac.uk (M.T.Russell) writes: > To the people complaining about `if (x == TRUE)': YOU ONLY USE `TRUE' AND > `FALSE' FOR ASSIGNMENT AND PARAMETER PASSING. It's a fairly simple rule. All of _us_ reading this newsgroup may follow that rule, but as an empirical observation a lot of people _don't_. I have seen too many Pascal programs where people wrote x: boolean; ... if x = TRUE then ... (and in Pascal this _works_) to be sanguine about the programmers in question learning better when they switch to C. I have also seen this kind of code in Algol programs, and if I were reading novice Ada programs I'm sure I'd see it there. I _have_ seen it in C code, and it was wrong. Let's not forget the Lisp Lesson: there is often something useful you could return instead of an anonymous "true". For example, if you are looking for a character in a string, instead of returning TRUE (it is there) or FALSE (it isn't) you could return a pointer to if it it's there or NULL if it isn't. If you program with that in mind, you really don't _care_ much about TRUE/FALSE -vs- 1/0, because it's rare that you have so little to say. > - the `&&', `||' and `!' operators demand bool operands and > yield a bool result. The ?: operator demands bool as its > first operand. The only other operators that take bool > operands are `!=', `==' and `&' (address of). Why should your proposed C variant be more restrictive than Pascal? In Pascal FALSE < TRUE is allowed, meaningful, and true. It is also allowed, meaningful, and true in Ada (LRM 3.5.3). -- You can lie with statistics ... but not to a statistician.