Standard extensions

Merlyn Leroy <Brian Westley> brian at digi-g.UUCP
Fri Nov 2 02:44:41 AEST 1984


#ifdef BUG
	Just to put in my $2E-2 on Things I Would Like to C in 'C':

Why isn't there a logical XOR operator?  There is & and && for bitwise and
logical AND, | and || for bitwise and logical OR, but only ^ for bitwise
XOR.  Why can't ^^ be used for logical XOR?  This is especially annoying
since you have to say:
(a || b) && (!a || !b)  (two evals of a and b, yuck) or something like:
((a == 0) != (b == 0))	(ugly! ugly! ugly! obscure, too)
instead of simply (a ^^ b).  If you know that the true values of a and b
are identical (instead of simply being non-zero), you can say a != b, but
this is not always the case.  Why not be consistent and offer logical XOR?

The other operation(s) I would like is circular shift.  zero fill << and >>
are very inefficient if you really want a circular shift.  There is a
problem with insuring that the bit pattern wraps at the boundary you want
(8, 16, 32, etc bits), but the compiler knows the size of the operand,
and you can always typecast to force it.  The operators could be
<> and ><, or <$ and >$, or <^ and >^, or anything that isn't ambiguous.
(If any of these are ambiguous, I don't care.  I'm sure <> and >< aren't,
but they can be confusing).

/* comments? */
							Merlyn Leroy
#endif



More information about the Comp.lang.c mailing list