Path: utzoo!utgpu!watserv1!watmath!att!rutgers!psuvax1!news From: flee@guardian.cs.psu.edu (Felix Lee) Newsgroups: comp.lang.c Subject: Re: TRUE and FALSE Message-ID: Date: 1 Sep 90 17:48:07 GMT References: <11215@alice.UUCP> <514@demott.COM> <2316@cirrusl.UUCP> <3835@sactoh0.SAC.CA.US> <26280@mimsy.umd.edu> <11474@crdgw1.crd.ge.com> <1990Aug31.145853.6125@cs.eur.nl> Sender: news@cs.psu.edu (Usenet) Organization: Penn State Computer Science Lines: 23 Nntp-Posting-Host: guardian.cs.psu.edu >#define BOOL( b ) ( (b) ? TRUE : FALSE ) >#define NOT( b ) BOOL( !(b) ) Personally, I use this set of macros: #define FALSE 0 #define CNAND(a,b) (!((a)&&(b))) #define CNOT(a) CNAND(a,a) #define CXOR(a,b) CNAND(CNAND(a,CNOT(b)),CNAND(b,CNOT(a))) #define CEQUIV(a,b) CNOT(CXOR(a,b)) #define COR(a,b) CEQUIV(a,CNAND(CNOT(a),CXOR(a,b))) #define CAND(a,b) CXOR(COR(a,b),CXOR(a,b)) #define TRUE COR(FALSE,CNOT(FALSE)) #define ISTRUE(a) CAND(TRUE,a) #define ISFALSE(a) CNOT(ISTRUE(a)) These may unfortunately overrun some compiler or preprocessor limits (TRUE expands to an 853 character expression, and ISFALSE(x) expands to 203677 characters). But they're otherwise quite portable, and I find the prefix style much more readable than C's cryptic infix expressions, especially when used in conjunction with a set of macros that provide LISP-ish control structures. -- Felix Lee flee@cs.psu.edu