Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site bbncca.ARPA Path: utzoo!linus!bbncca!keesan From: keesan@bbncca.ARPA (Morris Keesan) Newsgroups: net.unix Subject: Re: typedefs, etc. - (nf) Message-ID: <430@bbncca.ARPA> Date: Tue, 3-Jan-84 10:01:55 EST Article-I.D.: bbncca.430 Posted: Tue Jan 3 10:01:55 1984 Date-Received: Wed, 4-Jan-84 03:05:13 EST References: <1200@ucbcad.UUCP> Organization: Bolt, Beranek and Newman, Cambridge, Ma. Lines: 37 ----------------------------------- >ucbesvax!turner Dec 30 03:26:00 1983 >Re: returning crafty boolean expressions > typedef int BOOL; /* ?! */ >That's not what I do! I have (in ~turner/include/macros.h): > typedef enum { FALSE, TRUE } bool; >With this bool-type, the following causes a type-clash on return value warning: > bool yes( ) > { > return getchar( ) == 'y'; > } >I would have to (and am willing to) say, instead: > bool yes( ) > { > if (getchar( ) == 'y') > return TRUE; > else > return FALSE; > } >>>>>>>>> I question the utility of a 'bool' type which generates type-clashes with boolean expressions. However, if you insist on using it, do you object to return( (bool)(getchar() == 'y') ); ? This avoids the type-clash warning, and is guaranteed to work. Saying if( getchar() == 'y' ) return TRUE; else return FALSE; is only one step away from if( (getchar() == 'y') == TRUE ) return TRUE; else return FALSE; and equally silly. The whole point of boolean types/values is that they reflect the values which can be held by boolean expressions. -- Morris M. Keesan {decvax,linus,wjh12}!bbncca!keesan keesan @ BBN-UNIX.ARPA