-
Notifications
You must be signed in to change notification settings - Fork 858
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
Should multiple underscores be allowed between digits? #517
Comments
This is a survey with two choices. Please vote 👍 or 👎 on this comment (not the OP) for the following two alternatives: 👍 — the current spec is fine, and multiple underscores like If you would pick "c) Other", then please leave a comment below explaining in detail. :-) |
I can't think of any valid use cases for multiple consecutive underscores in numbers, and I don't think that the mere allowance of that behavior in a few other languages is enough to warrant allowing something non-useful in TOML. By disallowing them, it makes it more likely that TOML documents will be more obvious to readers, which is an important thing to encourage. |
I have thought of one possible use case, which would be to put two underscores between groups of hex digits, like |
Just studied a lot of code, and changed my vote to single '_' only. |
Cool, sounds like this is settled then. Thanks for the discussion! |
The TOML spec currently allows underscores between digits, but states:
This is slightly different from the semantics allowed in Java, C# (couldn't find a link, but tested), and F#. All three of these languages allow multiple underscores between digits, so that
3_____4
is a valid way to write the number 34 (thirty-four).On the other hand, Python 3.6 just added underscores between digits, and does NOT allow them to be doubled up (
3_4
is valid, but3__4
(two underscores) is not.) So while there does seem to be some consensus among much of the programming-language community that underscores between digits are a good idea, there is not yet a consensus about whether multiple underscores should be allowed.Since TOML has "obvious" right in the name, the most important question is "What is obvious here?". And that's a question best answered by a survey, because what is obvious to me may not be obvious to you. There are two different things that could be obvious:
Only allow a single underscore between digits (the current spec), because while it's pretty obvious what
2_147_483_647
means, the meaning of2___147___483___647
is not as immediately obvious: it's harder to read with the digits so separated. (And anyone who seriously writes the number 34 as3_____4
should be forced to write nothing but PHP for a year, as penance.)Change the spec to better match what C#, Java, and F# allow. Here, we're saying that "obvious" means "a syntax very similar to what most major languages allow". Even though I don't find
3_____4
to be obvious, most languages allow that, so it might be surprising to people to have that syntax be forbidden.So I think it's important to have this discussion now, before the current TOML spec is formalized as 1.0 and it becomes harder to make changes. I'd like to get other people's opnions. Should
3____4
be allowed, or forbidden?The text was updated successfully, but these errors were encountered: