Standard extensions (logical exclusive or)
Brandon Allbery
bsa at ncoast.UUCP
Sun Nov 11 02:19:11 AEST 1984
> Article <3081 at alice.UUCP>, from ark at alice.UUCP (Andrew Koenig)
+----------------
| Joseph Orost suggests a new operator ^^ such that
| a^^b
| would be equivalent to
| a? (b?0:1): (b?1:0)
|
| What is wrong with writing
| a!=b
| for this purpose?
C programmers like to cut corners; witness all those on1 messages that
depend on && evaluating as little as possible. It may be in K&R, but
I've seen too many harebrained implementations of too manu programs...
The problem with a!=b is that some of us use other corner-cutters: one
of mine is
if (index("AIJKLRaijklr", cmdchr)) dothis();
where index (strchr for USGers) returns either NULL or a pointer. This
will NOT work if you use != for an xor:
if (iscmd!=index("AIJKLRaijklr", cmdchr)) dothis();
is only true if !iscmd and !index(...), since index will usually NOT
return a 1...
--bsa
--
Brandon Allbery @ North Coast Xenix | the.world!ucbvax!decvax!cwruecmp!
6504 Chestnut Road, Independence, Ohio | {atvax!}ncoast!{tdi1!}bsa
(216) 524-1416 \ 44131 | E1439 at CSUOHIO.BITNET (friend's acct.)
---------------------------------------+---------------------------------------
`Confusion is my natural state.'
More information about the Comp.lang.c
mailing list