-
-
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
isnumber("") return true #14156
Comments
This seems to be consistent with the doc.
An empty string trivially satisfies this. |
One could equally well argue that julia> parse(Int, "")
ERROR: ArgumentError: premature end of integer: "" |
It's consistent with other similar functions and I don't think it's a good idea to make some of them special. |
Also note that julia> isnumber("¼")
true
julia> parse(Int, "¼")
ERROR: ArgumentError: invalid base 10 digit '¼' in "¼"
[inlined code] from ./strings/io.jl:66
in tryparse_internal at ./parse.jl:92
in tryparse_internal at ./parse.jl:136
in parse at ./parse.jl:146 |
I must admit it's also consistent with julia> all(Bool[])
true Looks like this is a well-established principle: https://en.wikipedia.org/wiki/Vacuous_truth But this gives rise to funny results like |
I think it would be better not to implicitly lift these functions to strings, and write |
Let's do that when jb/functions is ready. |
jb/functions was ready, wasn't it? Can we make this change now? |
yes though ideally it should be a deprecation so there's a limited window to get this into 0.6 |
Let's go ahead and deprecate the auto-vectorised version here. |
I also think this is a pretty surprising function since I would expect it to have something to do with the |
This also applies to all the other digit predicates, isprint, ispunct, islower, iscntrl, isalpha, etc. We can deprecate all of them, with the possible exception of |
PR #14387 merged all these functions into a single |
Yes please – let's go with that. |
That PR was pretty controversial, and also orthogonal to whether character property testing is lifted to strings. |
I don't think the contents of the PR were very controversial, except for the parts I debated in a long discussion with Scott (i.e. whether to use types or not). But you're right it's mostly orthogonal to this issue, I was just reacting to your statement "we can deprecate all of them". |
The text was updated successfully, but these errors were encountered: