-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add checked_abs() methods for unsigned ints and BigInt #13912
Conversation
This is consistent with other checked_* methods and allows writing more generic code.
+1. I'm satisfied with this change. One minor quibble. Shouldn't any tests of |
For types for which no overflow can happen during `abs`, this is equivalent | ||
to `abs(x)`. | ||
""" | ||
function checked_abs end |
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.
Why have you defined this?
If you want to assign to the function you can do:
"docstring"
checked_abs
after the method is defined. But IIUC this is no longer any different to attaching it to a method.
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.
I wanted a description that applies both to signed types, as well as to Unsigned
, BigInt
, and to any other unsigned type that could be added a method elsewhere. So it sounded more logical to attach it to the function, and only give type-specific details when needed (e.g. for Signed
below).
But I don't really understand how this works. Doesn't the method to which you attach the docstring make any difference? How are the docstrings sorted? Cf. #13911 I just filed today.
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.
Above is how you attach it to the function, you definitely should not create a dummy method to attach to.
IIUC docstrings are no longer attached to methods (they were previously), but just appended to the function docstring. There is a lot of confusion about this at the moment so I think it ought to be cleared up (hopefully with your issue :) )
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.
my mistake, I didn't realise that syntax made 0 methods.
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.
OK. So do you think this is correct or not? :-)
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.
Yes, LGTM.
RE the big int test thing: it's not the only bigint in test/int.jl and they'll be easy to find when/if they're every removed from base. So I think we can merge as is.
I'm not sure. None of the |
Add checked_abs() methods for unsigned ints and BigInt
Thanks to both of you! |
@nalimilan thanks to you as well. It was a pleasure collaborating with you. |
This is consistent with other checked_* methods and allows
writing more generic code.
CC: @MichaeLeroy