the logical xor operator! (John F. Haugh II, Karl W. Z. Heuer)

~XT4103000~Marc Mengel~C25~G25~6184~ mmengel at cuuxb.ATT.COM
Sat Jul 2 05:45:52 AEST 1988


>>Of course, if you're dealing with true boolean expressions (and I hold the
>>opinion that nothing else should be handed to a logical operator), then 
>>either "x != y" or "x ^ y" will do.
>Come on Karl, what's so terrible about the following common practice?
>	if (some_pointer && ...) {
>		...
>	}

Ah, but fortunately C gave us a cheap and easy way to convert to
"Boolean" --  so "!!x ^ !!y" does pretty well.  I think the short
circuit evaluation is the real reason -- after all, you could
short circuit evaluate "x & y" if x is 0, and "x | y" if x is ~0,
but you *don't* because then you would have to use explicit temp
variables to evaluate both sides of the bitwise operator.
-- 
 Marc Mengel			       
				
 attmail!mmengel	
 {lll-crg|mtune|ihnp4}!cuuxb!mmengel



More information about the Comp.std.c mailing list