Path: utzoo!attcan!uunet!husc6!bloom-beacon!oberon!sdcrdcf!trwrb!scgvaxd!ashtate!dbase!alex From: alex@dbase.UUCP (Bob Alexander) Newsgroups: comp.std.c Subject: Re: the logical xor operator! Message-ID: <400@dbase.UUCP> Date: 1 Jul 88 18:00:30 GMT References:<1719@ogcvax.ogc.edu> <1309@ark.cs.vu.nl> <4772@haddock.ISC.COM> <12178@mimsy.UUCP> <833@garth.UUCP> Reply-To: alex@dbase.UUCP (Bob Alexander) Organization: Ashton Tate Devlopment Center Glendale, Calif. Lines: 23 In article <833@garth.UUCP> smryan@garth.UUCP (Steven Ryan) writes: >The lack of a boolean exclusive-or is probably cultural. Xor is important >for bit fiddling, but few predicates use it. An equivalence operator (even >if it is just a negated xor), on the other hand is useful for boolean but >not bits. > I would guess that much of the reason for including || and && in C was to provide the advantage of their short-circuiting properties. Short-circuiting could not be done with ^^. I wouldn't mind having it around, for completeness, but I would probably rarely use it. Just for kicks, how about: #define logical(x) ((x) != 0) /* logical affirmation */ #define logicalxor(x,y) (logical(x) != logical(y)) /* logical xor */ #define logicaleq(x,y) (logical(x) == logical(y)) /* logical equivalence */ For as often as I would use them, this would suffice. I would probably use the first one the most. Disclaimer: I accept no liability for possible misuse of the word "affirmation". Furthermore, the above definitions might not work at all -- haven't tried 'em.