Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite <: Real? #11

Open
cjdoris opened this issue Jun 6, 2020 · 2 comments
Open

Infinite <: Real? #11

cjdoris opened this issue Jun 6, 2020 · 2 comments

Comments

@cjdoris
Copy link
Owner

cjdoris commented Jun 6, 2020

Currently Infinite is a subtype of Real. But now we have InfExtendedTime. Should we have Infinite <: Any instead? Options:

  • Leave Infinite <: Real, but also allow Infinite to promote to TimeType.
  • Change Infinite <: Any. This means you can't do arithmetic between Real and Infinite (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
Copy link
Owner Author

cjdoris commented Jun 6, 2020

My current proposal:

  • Have Infinite <: Any, with two values and -∞ (aka PosInf and NegInf) as at the moment.
  • Also have InfiniteReal <: Real, with two values PosInfReal and NegInfReal. Promotion between Real and Infinite yields InfiniteReal. Real(∞) is PosInfReal. Promotion between any T<:Real and Infinite or InfiniteReal yields InfExtendedReal{T}. Users should mostly not care about this type, and just need to know about Real(∞), or explicitly promote things.
  • Similarly, have InfiniteTime <: TimeType, PosInfTime, and TimeType(∞).

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).

@cjdoris cjdoris changed the title Infinity <: Real? Infinite <: Real? Jun 10, 2020
@jtrakk
Copy link

jtrakk commented Mar 5, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants