more on additional conditional operators in C
David G. Hough on validgh
dgh
Sat Aug 11 08:16:15 PDT 1990
> * Kahan proposes adding !< !<= !> !>= conditionals to C. You could go further
> * and add e.g. <? <=? >? >=?. Among the four possible results of a comparison
> * (equal, less, greater, unordered),
> *
> Why not make the !cc conditions without ? perform according to the
> standard's NOT(cc)?
>
> The definition of !>= seems like a gratuitous deviation from the IEEE
> standard. Why make it redundant with <? when that conveys the message?
> Hiding the ? by using the negation of the test seems like a step back
> rather than an improvement.
The question is whether !>= should be the same as NOT(>=). In the IEEE 754
spec, NOT(<=) refers to what happens when you reverse the sense of a
conditional <= , as often happens in code generation; in this case, if
the source code was <= then the presumption is that it's old code that
gave no thought to unordered results and hence should generate an invalid
exception if unordered results are encountered.
In contrast the proposed explicit C syntax !>= is new and hence need not
generate an invalid exception for unordered results since presumably
they've been considered.
There are some good questions about whether all possible relational
symbols are worth supporting in C. There are certainly advantages
to incorporating a complete orthogonal set. I like the idea of
writing if (x ? y) rather than if (unordered(x,y)) or if ( x !<=> y)
but whether the ? character could be available for use in conditionals
considering its other uses in (cond)?: and trigraphs I'll leave to
the parser constructors to decide.
More information about the Numeric-interest
mailing list