🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1791

Re: Why no logical XOR operator?

#1791
From: Tim Hollebeek
Date: Tue, 22 Aug 1995 02:22
34 lines
1885 bytes
In article <40sp1t$lbc@cd4680fs.rrze.uni-erlangen.de>,
Robert Risack <rtrisack@faui01.informatik.uni-erlangen.de> wrote:
>Hello.
>
>I'm wondering why there isn't a logical XOR operator (eg. ^^)
>though there is a bitwise one (ie. ^).
>
>The other bitwise operators ( & | and ~ ) have their logical
>aquivalent ( && || and ! ). And the XOR is IMHO not that uncommon.

There is a crucial difference; the evaluation of && and || can be
shortcut, while no such trick works for (the hypothetical) ^^, making
them quite different beasts.

&& and || are _not_ simply the boolean equivalents of & and |.  For
example, the following common code:

if (x && x->foo) { ... } 

is perfectly safe, while the bitwise version:

if (!!x & !! x->foo) { ... }

generates a null-pointer reference if x is zero.

-- 
Tim Hollebeek        |"What is love? 'tis not hereafter; Present mirth hath
PChem Grad Student   |present laughter; What's to come is still unsure: In
Princeton University |delay there lies no plenty; Then come kiss me, sweet and
---------------------|twenty, Youth's a stuff will not endure." -Twelfth Night

[ 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: <41bchi$d21@cnn.Princeton.EDU>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
References: <40sp1t$lbc@cd4680fs.rrze.uni-erlangen.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: tim@franck.Princeton.EDU (Tim Hollebeek)
Newsgroups: comp.std.c++
Subject: Re: Why no logical XOR operator?
Date: 22 Aug 1995 02:22:51 GMT
Organization: Princeton University
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <41bchi$d21@cnn.Princeton.EDU>
References: <40sp1t$lbc@cd4680fs.rrze.uni-erlangen.de>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: franck.princeton.edu
Content-Length: 1105
Originator: clamage@taumet