-
Notifications
You must be signed in to change notification settings - Fork 73
Align tonumber with current Luau number syntax #160
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
base: master
Are you sure you want to change the base?
Align tonumber with current Luau number syntax #160
Conversation
|
imo the backwards compatibility loss isnt worth the change here |
|
what backwards compatibility will be lost here? |
|
today, a string passing tonumber means that every character is an ascii digit - this breaks that guarantee |
I haven't found any code that this would break, and majority of the cases where I've seen people ensuring a string is valid ASCII uses the string library to do so and not Also I don't think hexadecimal strings are made up of solely digits? As this is valid today: print(tonumber("0xFFFF")) --> 65535 |
|
that code is not valid today - you have to pass a second argument to tonumber to make it parse hexadecimal. just because you cant find code that would break doesnt mean that a case this simple doesnt exist somewhere |
|
the idea that breaking changes only matter if they affect significant customers is a bad one |
this is definitely not true. to number for example supports "nan", "inf", "1e3", "nan(...)", "1.4". ascii digits are only 0-9, and tonumber already supports scientific notation and numbers not normally represented through mere digits. |
|
okay sure, its still breaking backwards compatibility without adding significant value - use gsub first if you really want this. as is frequently the case, the solution to your problem is not more language features, but is instead writing more code |
|
what backwards compat is it breaking? |
|
tonumber also supports hexadecimal, without specifying base, like lynn posted right now already. aligning it would only make sense. |
what do you mean i ran that with the luau cli |
makes the motivation section focus more so on `tonumber`'s current odd behavior
Rendered