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

Implementing fallback methods for checked_* #7

Closed
kimikage opened this issue Aug 26, 2020 · 2 comments
Closed

Implementing fallback methods for checked_* #7

kimikage opened this issue Aug 26, 2020 · 2 comments

Comments

@kimikage
Copy link
Collaborator

Since Base.Checked originally targets integer arithmetic, no fallback is provided for non-integer types.
https://github.com/JuliaLang/julia/blob/d84cd4d5ff0e7a51ae5ad4c1a9ac7b2999bd242e/base/checked.jl#L18-L30

It is easy to get method errors for user-/package-defined types because @checked replaces operators regardless of the existence of the methods.

Of course, it's unsafe to fall back to unchecked methods, but this seems to be a necessary measure for convenience.

@kimikage
Copy link
Collaborator Author

For specific types, it might be a good idea to have an API like warn_no_op(op::Symbol, ::Type) = nothing and embed it in the fallbacks in order to easily switch warnings (or errors) for unsafe fallbacks.

@kimikage
Copy link
Collaborator Author

Additional functionality will be added in OverflowContexts.jl.

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

1 participant