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

isnumber(::Number) undefined #23767

Closed
dalum opened this issue Sep 19, 2017 · 6 comments
Closed

isnumber(::Number) undefined #23767

dalum opened this issue Sep 19, 2017 · 6 comments

Comments

@dalum
Copy link
Contributor

dalum commented Sep 19, 2017

Is there a reason isnumber(::Number) is left undefined? There are a billion other ways to check for it, I guess, but it's a bit odd that it has only been defined as a function on Char. I don't have a good use case for it, just one of surprise that the function tab-completed but didn't do what I expected. And also that I define my own isnumber with isnumber(::Number) = true. Would be nicer just to extend the one in Base with my own types, so other people wouldn't have to overwrite my isnumber for their personal number types that for some reason don't inherit from Number.

@yuyichao
Copy link
Contributor

What do you want it to do? It's for checking if a character is a number so do you want it to be isnumber(::Number) = true or isnumber(a::Number) = isnumber(Char(a))? Better to leave this undefined I think.

@StefanKarpinski
Copy link
Member

Yes, it does what's documented, but the name makes this quite confusing. It should at the very least have a better name or be scoped to a string-specific module. There has previously been talk of folding all character class checks into a single function with an enum argument for the class.

@dalum
Copy link
Contributor Author

dalum commented Sep 19, 2017

Sorry, yes, I would suggest isnumber(::Number) = true. I understand that it checks if a Char is in the number range, and there is nothing inherently wrong with the fact that it only does that, but it is a surprising behaviour when you just type isn<tab> and sees that "oh, there's a function called something that sounds like what I want". It's a bit like defining ismatrix to only check if a string parses into a Matrix.

@omus
Copy link
Member

omus commented Sep 19, 2017

Maybe this should be renamed to isnumeric? I'm not sure isnumber(::Number) needs to be defined as you should be doing isa(x, Number) instead.

@yuyichao
Copy link
Contributor

So this can be closed and any discussion about changing the name should go to #14347 where previous discussion is. It doesn't make sense to define isnumber(::Number).

@nalimilan
Copy link
Member

So let's reopen #14347? :-)

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

5 participants