Article View: comp.std.c++
Article #1807Re: Why no logical XOR operator?
From: Doug Moore
Date: Tue, 22 Aug 1995 14:54
Date: Tue, 22 Aug 1995 14:54
29 lines
1914 bytes
1914 bytes
Shankar Unni (shankar@engr.sgi.com) wrote:
: Robert Risack (rtrisack@faui01.informatik.uni-erlangen.de) wrote:
: > I'm wondering why there isn't a logical XOR operator (eg. ^^)
: > though there is a bitwise one (ie. ^).
: Oh, please!
: We've been through exactly this specific battle about once every semester
: (hint) on comp.{lang,std}.c ... Anyone care to summarize the arguments?
While I agree that it is a common and basically pointless question, I
can't believe that a message which is nothing but a flame made it past
moderation.
[ Point well taken. My mistake. -sdc ]
The answer is that there is no such thing as a short-circuiting
exclusive-or. With && and ||, the second argument may not be
evaluated. With the proposed ^^, both arguments would have to be
evaluated. There is already a perfectly good logical exlusive-or
operator for bools: operator !=. If you want the logical exclusive-or
of non-booleans (a dubious proposition IMHO), you have to go for !a !=
!b. Such a strange computation deserves slightly strange notation.
dougm@rice.edu (Doug Moore)
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<41bf4j$d70@larry.rice.edu>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<40sp1t$lbc@cd4680fs.rrze.uni-erlangen.de> <41as6m$d95@fido.asd.sgi.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: dougm@rice.edu (Doug Moore) Newsgroups: comp.std.c++ Subject: Re: Why no logical XOR operator? Date: 22 Aug 1995 14:54:31 GMT Organization: Rice University, Houston, Texas Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <41bf4j$d70@larry.rice.edu> References: <40sp1t$lbc@cd4680fs.rrze.uni-erlangen.de> <41as6m$d95@fido.asd.sgi.com> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: kuhn.caam.rice.edu X-Newsreader: TIN [version 1.2 PL2] Content-Length: 1011 Originator: clamage@taumet