-
Notifications
You must be signed in to change notification settings - Fork 34
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
[RFC] Add depwarn in constructor of Fixed{T,f} where f == 8sizeof(T) #159
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 A small suggestion to print the requested values in the warning/error message. I wrote it out in just one place, but if you like it consider adding it to the DomainError
messages too.
src/fixed.jl
Outdated
Fixed{T, f}(i::Integer, _) where {T,f} = new{T, f}(i % T) | ||
function Fixed{T, f}(i::Integer, _) where {T, f} | ||
if f == bitwidth(T) | ||
Base.depwarn("The `f`, which is the same as the number of rawtype bits, will be denied in the future.", :Fixed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Base.depwarn("The `f`, which is the same as the number of rawtype bits, will be denied in the future.", :Fixed) | |
Base.depwarn("`Fixed` reserves one bit for the sign. Support for `f=$f` with raw type `T=$T` will be removed in a future release.", :Fixed) |
To avoid a performance hit from the interpolation you might need the @noinline
trick, i.e.,
@noinline dowarn(f, T) = Base.depwarn(...)
f == bitwidth(T) && dowarn(f, T)
(Probably not necessary if DCE runs before the allocation pass, I'm not sure of the order so you can check the LLVM code if you want to be sure.)
This also adds the domain checks for `f` in the constructors.
I changed the messages. |
But do you pay it even when it doesn't issue the warning? For example, check the LLVM for |
"2,000,000%" means DCE works fine. I checked Edit: |
I have to submit some PRs and merge them, so there is still time to release v0.8.0. For now, let's step forward. |
If we officially deprecate
Fixed{Int8, 8}
and so on, it is better to add a depwarn early. (cf. #155)However, I also think it is another possible option to continue to support them.
This also adds the domain checks for
f
in the constructors. Because of the dead code elimination, there is no performance regression for validf
in most use cases.