With user-defined types and overloaded operators (like in Ada)
this is easy to set up (I will spare you the tedious Ada Syntax).
type tempresult = record
val: real
tst: bool
end
operator "<" (a: real, b: real) bool = ... the normal comparison
operator "<" (a: real, b: real) tempresult =
(val => b, tst => a < b)
operator "<" (a: tempresult, b: real) bool =
(a.tst and a.val < b)
operator "<" (a: tempresult, b: real) tempresult =
(val => b, tst => a.tst and a.val < b)
Aren't data types wonderful?
--
Gordon V. Cormack CS Department, University of Waterloo
gvco...@watdaisy.uucp gvcormack%watd...@waterloo.csnet
Sure, but I have been wondering what all the fuss is. x < y < z
is not all that exciting, and not much shorter than what it is
supposed to shorten. Certainly I don't see compilers generating
better code from it.
There are lots of valuable things you can do with more general
languages, but I don't think this is one of them. I can't imagine
a language designer deliberately complicating things just to support
this one.
--
Brad Templeton, Looking Glass Software Ltd. - Waterloo, Ontario 519/884-7473
Think back many many years ago to CS 101 and the first time you had
to test whether a number was between two other numbers: how did you
instantly and naturally write it down ? And what did the compiler
say?
>There are lots of valuable things you can do with more general
>languages, but I don't think this is one of them. I can't imagine
>a language designer deliberately complicating things just to support
>this one.
>
"Valuable" includes "more understandable", not just "more powerful" :-)
garry wiegand (garry%cadi...@cu-arpa.cs.cornell.edu)