`Infinite <: Real`?
Opened this issue · 2 comments
cjdoris commented
Currently Infinite
is a subtype of Real
. But now we have InfExtendedTime
. Should we have Infinite <: Any
instead? Options:
- Leave
Infinite <: Real
, but also allowInfinite
to promote toTimeType
. - Change
Infinite <: Any
. This means you can't do arithmetic betweenReal
andInfinite
(without adding a lot of methods for+
,*
etc to promote arguments) but maybe that's not really a problem? - Have two infinities: a real one and a time one?
cjdoris commented
My current proposal:
- Have
Infinite <: Any
, with two values∞
and-∞
(akaPosInf
andNegInf
) as at the moment. - Also have
InfiniteReal <: Real
, with two valuesPosInfReal
andNegInfReal
. Promotion betweenReal
andInfinite
yieldsInfiniteReal
.Real(∞)
isPosInfReal
. Promotion between anyT<:Real
andInfinite
orInfiniteReal
yieldsInfExtendedReal{T}
. Users should mostly not care about this type, and just need to know aboutReal(∞)
, or explicitly promote things. - Similarly, have
InfiniteTime <: TimeType
,PosInfTime
, andTimeType(∞)
.
This way, the user can mostly just use ∞
and promotion will do the right thing --- e.g. Interval(3,∞)
will promote to InfExtendedReal{Int}
. But you'll need to do 1+Real(∞)
instead of 1+∞
(unless we provide promotion methods for common arithmetic operations).
jtrakk commented
I realize that T(x)
isn't guaranteed to return a T
, but I do normally expect it to. Why not just let Real(∞)
raise an error?