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

Add checked_abs() methods for unsigned ints and BigInt #13912

Merged
merged 1 commit into from
Nov 8, 2015
Merged

Conversation

nalimilan
Copy link
Member

This is consistent with other checked_* methods and allows
writing more generic code.

CC: @MichaeLeroy

This is consistent with other checked_* methods and allows
writing more generic code.
@MichaeLeroy
Copy link
Contributor

+1. I'm satisfied with this change.

One minor quibble. Shouldn't any tests of checked_abs as applied to BigInt be in test/bigint.jl rather than in test/int.jl?

For types for which no overflow can happen during `abs`, this is equivalent
to `abs(x)`.
"""
function checked_abs end
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

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.

Copy link
Member Author

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? :-)

Copy link
Member

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.

@nalimilan
Copy link
Member Author

One minor quibble. Shouldn't any tests of checked_abs as applied to BigInt be in test/bigint.jl rather than in test/int.jl?

I'm not sure. None of the checked_* functions are tested in bigint.jl, so I found it more logical to put it in int.jl. BigInt is already used in int.jl anyway.

hayd added a commit that referenced this pull request Nov 8, 2015
Add checked_abs() methods for unsigned ints and BigInt
@hayd hayd merged commit df3cd41 into master Nov 8, 2015
@hayd hayd deleted the nl/checked_abs branch November 8, 2015 17:46
@nalimilan
Copy link
Member Author

Thanks to both of you!

@MichaeLeroy
Copy link
Contributor

@nalimilan thanks to you as well. It was a pleasure collaborating with you.

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 this pull request may close these issues.

3 participants