🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1688

Re: Why no logical XOR operator

#1688
From: Cameron Simpson,Uhmmm..???? Who ...
Date: Thu, 13 Sep 1990 09:34
20 lines
1262 bytes
From article <1990Sep12.154515.18460@druid.uucp>, by darcy@druid.uucp (D'Arcy J.M. Cain):
| Recently I had occasion to write something like the following code:
| 	if ((!x && (y & z)) || (x && !(y & z))
| 		something();
| Which would have been simpler as:
| 	if (x ^^ (y & z))
| 		something();
| If there was such a thing as a '^^' operator.  Does anyone know why C left
| out the logical XOR operator?

I can envisage two reasons:
	- It looks like && and ||, so it should short-circuit.
	  This doesn't make sense for XOR.
	- What's wrong with saying:
		!!x ^ !!y
	  which accomplishes exactly what you want.
	  I'm tempted to use the phrase "insufficient utility".

- Cameron Simpson
  cameron@spectrum.cs.unsw.oz.au
Technical Details
Message-ID: <849@usage.csd.unsw.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!clyde.concordia.ca!mcgill-vision!snorkelwacker!usc!samsung!munnari.oz.au!metro!usage.csd.unsw.oz.au!spectrum!cameron
References: <1990Sep12.154515.18460@druid.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!clyde.concordia.ca!mcgill-vision!snorkelwacker!usc!samsung!munnari.oz.au!metro!usage.csd.unsw.oz.au!spectrum!cameron
From: cameron@usage.csd.oz (Cameron Simpson,Uhmmm..???? Who knows)
Newsgroups: comp.std.c
Subject: Re: Why no logical XOR operator
Message-ID: <849@usage.csd.unsw.oz.au>
Date: 13 Sep 90 09:34:25 GMT
References: <1990Sep12.154515.18460@druid.uucp>
Sender: news@usage.csd.unsw.oz.au
Reply-To: cameron@spectrum.cs.unsw.oz.au (Cameron Simpson)
Organization: none
Lines: 20