Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!think!mit-eddie!barmar From: barmar@mit-eddie.MIT.EDU (Barry Margolin) Newsgroups: net.lang.c Subject: Re: What should be added to C (booleans) Message-ID: <2176@mit-eddie.MIT.EDU> Date: Wed, 4-Jun-86 02:13:14 EDT Article-I.D.: mit-eddi.2176 Posted: Wed Jun 4 02:13:14 1986 Date-Received: Thu, 5-Jun-86 19:37:35 EDT References: <590@brl-smoke.ARPA> <3570@nsc.UUCP> <1462@mmintl.UUCP> <3414@ut-ngp.UUCP> <236@iscuva.UUCP> <167@zaiaz32.UUCP> Reply-To: barmar@mit-eddie.UUCP (Barry Margolin) Organization: MIT, EE/CS Computer Facilities, Cambridge, MA Lines: 40 In article <167@zaiaz32.UUCP> rlb@zaiaz32.UUCP writes: >> >> provided that the two expressions evaluate to whatever a boolean int is >> locally (1 or -1). {BTW I usually use set_me_true = (1 == 1)} >> > >This worries me, much the same as when I see someone code: > > #define FALSE 0 > #define TRUE !FALSE > >Makes me think that the person writing may really not know that a C >"boolean" expression (expression formed with the logical/relational operators) >is *defined* to be either 1 or 0. I think your worries are unfounded. The difference between (1 == 1) and 1 is that the former indicates to human readers of the code that the expression is being used for its truth value. In the statement var = 1; the reader is likely to assume that var is going to be used arithmetically. To calm your fears about the #define's, let me try a little satirical analogy: --------- This bothers me, much the same as when I see someone code file = fopen (...); Makes me thing that the person writing may really not know that the standard I/O library function "fopen" is *defined* to return a file. ---------- The point of the analogy is that there is nothing wrong with using menmonic names for things. While it may be true that C defines 0 and 1 to be falsity and truth, it doesn't hurt to use macros to say what you really mean. -- Barry Margolin ARPA: barmar@MIT-Multics UUCP: ..!genrad!mit-eddie!barmar