Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site gatech.CSNET Path: utzoo!watmath!clyde!burl!ulysses!gatech!arnold From: arnold@gatech.CSNET (Arnold Robbins) Newsgroups: net.lang.c Subject: Re: Cryptic C (YES/NO vs. TRUE/FALSE + other thoughts) Message-ID: <989@gatech.CSNET> Date: Fri, 23-Aug-85 12:57:20 EDT Article-I.D.: gatech.989 Posted: Fri Aug 23 12:57:20 1985 Date-Received: Sun, 25-Aug-85 05:25:34 EDT References: <2913@ncsu.UUCP>, <709@brl-tgr.ARPA> <5884@utzoo.UUCP> Organization: Pr1mebusters! Lines: 67 Summary: some thoughts on coding style for binary symbolic values In article <5884@utzoo.UUCP>, henry@utzoo.UUCP (Henry Spencer) writes: > > typedef int bool; > > #define false 0 > > #define true 1 > > It's interesting to note that Kernighan&Plauger use "yes" and "no" rather > than "true" and "false", and my own reaction is that the code often reads > better that way. Now that's something to *really* start a raging debate > about... :-) > -- > Henry Spencer @ U of Toronto Zoology Well, this can get carried too far. I have worked with code based on Software Tools stuff that looks like dowrite (file, YES, NO, NO, YES); Now, can you tell what the heck it is doing? Especially when the code for dowrite() is 700 lines down in another file? I've often thought that a style like #define FORCEWRITE 1 #define NOFORCE 0 #define APPEND 1 #define NOAPPEND 0 dowrite (file, FORCEWRITE, APPEND, ....); /* call */ int dowrite (file, force, append,...) /* actual procedure */ ... { if (force) .... if (append) .... } is much clearer than the first style. This is the kind of thing, if anything, that "enums" would be most useful for (no flames about how poorly enums are implemented. I'm talking conceptually here.). Overall, TRUE or FALSE or YES or NO doesn't make much difference to me. However, I much prefer the following if (boolean) something and boolean = (x && y || c >= d); to the overly verbose if (boolean == TRUE) something if (x && y || c >= d) boolean = TRUE; else boolean = FALSE; Now *that* should start a really raging debate! :-) -- Arnold Robbins CSNET: arnold@gatech ARPA: arnold%gatech.csnet@csnet-relay.arpa UUCP: { akgua, allegra, hplabs, ihnp4, seismo, ut-sally }!gatech!arnold Hello. You have reached the Coalition to Eliminate Answering Machines. Unfortunately, no one can come to the phone right now....