Boolean Operators Slighted in C

rcd at nbires.UUCP rcd at nbires.UUCP
Fri May 9 15:31:54 AEST 1986


> >Btw, you can't have *all* operators extended with "=".  How would you write
> >"v = v < e;"?  (Not that it's useful.)

A more precisely stated rule, for C, would be that you can extend any
dyadic operator whose result type is the same as the type of the first
operand, but...

> 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;

Cf. Icon, in which the success/failure of a conditional is separate from
its value.  Icon's <= operator (as all of its relational operators) yields
the value of its right operand if it succeeds; otherwise it fails (meaning
no result is produced).  The semantics described above in ">" is just that
of Icon's <:= operator.
-- 
Dick Dunn	{hao,ucbvax,allegra}!nbires!rcd		(303)444-5710 x3086
   ...Cerebus for dictator!



More information about the Comp.lang.c mailing list