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

Separation to CheckedArithmeticCore #6

Closed
kimikage opened this issue Aug 26, 2020 · 2 comments · Fixed by #8
Closed

Separation to CheckedArithmeticCore #6

kimikage opened this issue Aug 26, 2020 · 2 comments · Fixed by #8

Comments

@kimikage
Copy link
Collaborator

From the beginning of this package, I have believed that the dependencies on this package would bring in trouble. (cf. JuliaMath/FixedPointNumbers.jl#146 (comment))

The "features" provided by CheckedArithmetic are on a higher level than packages that provide types like FixedPointNumbers. The dependency of a low-level package on a high-level package leads to roughly two problems.

  1. Keeping up with compatibility
    Until CheckedArithmetic reaches v1.0, packages that provide numeric types are implicitly required to keep up with the new version when there are changes to the implementation or functionality of CheckedArithmetic, even if they do not break the existing API.

  2. Weight limit of CheckedArithmetic
    If CheckedArithmetic is "heavy", it affects all users of the package which (indirectly) depend on the package providing the numeric types. Therefore, CheckedArithmetic is implicitly required to be lightweight. I suspect that the Cassette's injection feature could be useful in "end-user" code, but I don't think it is a good idea for packages which provide numeric types to be dependent on Cassette.

I would like to make the CheckedArithmetic support not only checked arithmetic, but also wrapping and saturating arithmetic. (cf. JuliaMath/FixedPointNumbers.jl#152 (comment)) And in the future, I would like to integrate the features into Base(Base.Checked). With this perspective, I think it would be beneficial to make the APIs and the implementations separate.

@timholy
Copy link
Member

timholy commented Sep 10, 2020

I approve of this plan.

@kimikage
Copy link
Collaborator Author

It's debatable as to which scope should be moved to the CheckedArithmeticCore.

  1. function definitions
  2. fallback implementations with Any
  3. implementations for Base types
  4. implementations for "stdlib" types

I think 1. and 2. should be in CheckedArithmeticCore; 3. and 4. could be included as well, but I have some questions about the current implementations. For example:

safearg_type(::Type{Bool}) = Bool # these have a special meaning that must be preserved

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

Successfully merging a pull request may close this issue.

2 participants