Boolean Operators Slighted in C

Andrew Koenig ark at alice.UucP
Tue May 6 04:35:49 AEST 1986


>>Btw, you can't have *all* operators extended with "=".  How would you write
>>"v = v < e;"?  (Not that it's useful.)
> I think it's useful!  As written, of course, it's semantically invalid,
> but what you really mean is "v <= e" (sic) or, to demonstrate where it's
> really useful,
>     array[horrendous] [subscript] [list] <= bigexpr;
>  rather than 
>     if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr;
> Now "<=" already means something else so this syntax is not acceptable.
> How about "v < = e" with a mandatory blank?  This is atrocious human
> engineering but at least is parseable.  Anybody have any better ideas?

You have suggested that

	v < = e

should mean

	if (v < e) v = e

but this is not parallel to the other `=' operators.  Instead,
if it means anything at all it should mean

	v = v < e

In other words, afterwards v is either 1 or 0 depending on the
value of e and the previous value of v.

But I can't imagine when I'd ever want to use this in practice.
Maybe we should just leave the language alone.



More information about the Comp.lang.c mailing list