The nonexistent ^^ operator

Darren Morbey darren at revcan.UUCP
Thu Apr 25 03:01:26 AEST 1991


I left as an exercise on making
#define XOR(A,B) ( (!(A)&&(B)) || ((A)&&!(B)) )
execute A twice and B no times (and B twice.)
The only respondent correctly identified this as operands with
side effects.  In this case, XOR(++x,b) executes B:
  no times  if x is initially -2.
  twice     if x is initially -1.
The prize goes to Ian Collier (Ian.Collier at prg.ox.ac.uk) for submitting
something like this (and being the only one to do so.)

As I was reviewing some of the responses and followup articles
to the logical XOR question, I came across a pretty good argument for
not having ^^.  This article comes from a "Dan," who says "since you
"can always implement a non-short-circuit logical operator, there's no
"reason for the language to provide any logical operators other than
"the short-circuit ones."

Due to the end of my co-operative work term on Friday, I'm unable
to accept any responses anymore. :-(  I may be able to get back on
in university ( I don't know though ).  I would like to thank all
of you for listening and responding to my question.

[ Darren Morby     +1 613 957 9281     {uunet|lsuc|fts1}!revcan!darren ]
[ Revenue Canada Taxation, 3052-400 Cumberland St, Ottawa,ONT  K1A 0L8 ]



More information about the Comp.lang.c mailing list