[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rational infinity

An alternative to JonL's proposal (which encodes rational infinities as
1/0 and -1/0) would be to put the infninity(ies) in a separate class,
under number, but not part of rational or ratio or integer. 

I think this is better than defining infinity using 1/0 or any other
encoding because:

a)  CLtL alludes to such a possibility.
b) it is reasonable to want to define an operation as working on, say,
integers including +infinity and -infinity, but not arbitrary other
ratios.  That is, the infinities are more an extension of the integer
type than the ratio type.
c) it doesn't require modification of definitions which are *not* valid
for infinity. For example, you might want to leave +, -, * and /
undefined for infinity, but define > >= = /= < <=. 
d) adding signed infinity in this way doesn't preclude adding a
projective unsigned infinity. 

I claim that the handling of IEEE floating point infinities was a good
design for programming languages where variables must be type declared,
and that one couldn't have a variable (binding? oops, wrong discussion)
which at various times contained  floating point numbers and at other
times contained NANs. A Lisp embedding of IEEE floating-point which made
NaNs a separate class (type) would have the advantage of being able to
more simply defining (or not defining) behavior of operations on them.