Proposal #143: Numeric literals added digit separators with strict rules for placement. It missed some use-cases. In order to address this, remove placement rules for numeric literals.
Digit separator placement rules are too strict:
Proposal #143: Numeric literals added digit separators with strict rules for placement:
2_147_483_648.0x7FFF_FFFF.e
or mandatory p) as described in the previous bullets. For example,
2_147.483648e12_345 or 0x1_00CA.FEF00Dp+240b1_000_101_11.This was asked on Issue #1485: Reconsider digit separators, where a proposal was requested.
Switch to simple rules: a single digit separator can appear between any two digits. For example:
1_2_30xA_B_C1_2.3_4e5_6For decimal separators, we could enforce 3-digit groupings if digit separators are used at all.
Advantages:
Disadvantages:
1_00000),
dates (01_12_1983), credit cards (1234_5678_9012_3456), or identity
numbers such as US social security numbers (123_45_6789).
Note that any regular grouping rule can present similar issues for Indian digit grouping conventions.
Proposal #143: Numeric literals chose 3-digit decimal groupings.
Given there are overall advantages to not enforcing regular digit conventions, including for hex digits, it seems unnecessary to conform to the currently established decimal conventions. While this removes the enforcement, the resulting accidents are considered a reasonable risk.
In theory a code linter could be told to prefer certain formats with options to change behavior, although that may remain too low benefit to implement.
Hexadecimal digit groupings could be enforced along two axes:
F_FF) or 4 (F_FFFF) characters, corresponding to one or two
bytes respectively.FF_FF_FF_FF, or irregular as in FF_FFFFF_FF which skips one
placement.Proposal #143: Numeric literals chose 4-digit with regular placement.
Advantages:
Disadvantages:
00_B0_D0_63_C2_26) and UUIDs have particular groupings
(123E4567_E89B_12D3_A456_426614174000).While it may be that enforcing 2 character (one byte) groupings with irregular placement would prevent sufficient errors versus the developer inconvenience risks, it risks becoming an outlier and for only very loose enforcement.
Similar to the preceding conclusion, leaving these issues to code linters may be best.
Proposal #143: Numeric literals appears to disallow digit
separators in fractions. That is, in 1.2345, 1.23_45 is disallowed. This
proposal changes that.
Advantages:
. for another
_ separator, as in 1_234_567.890_123_456.Disadvantages:
We'll allow digit separators in fractions.