-
Notifications
You must be signed in to change notification settings - Fork 15
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
429 Add hex and binary literals and allow underscores #433
Conversation
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much appreciated (and no need for me to offer a pull request for this one anymore).
Thoughts:
- Most languages seem to also support both
0X
and0B
, but asX
isn’t legal in character references either, I agree it’s probably better to only offer the lower-case options. - The new grammar does not allow integer literals to start with underscores (as
_1
is a valid name test). To be consistent with other languages, maybe we should also disallow underscores at the end ofDigits
and the start/end ofHexDigits
andBinaryDigits
?
(: legal :) 0b0_1, 0x2_3, 4_5, 6_7.8_9,
(: illegal :) _1, 2._3, 4e_5, 6.7e_8
(: disallow? :) 0b_0, 0b1_, 0x_2, 0x3_, 4_, 5.6_, 7.8e9_
Suggested grammar rules:
|
Observation from Reece (QT4 CG Meeting 032):
|
Accepted at meeting 032 |
Both Java and C# appear to allow adjacent underscores (and both prohibit terminal underscores). |
Addresses issue #429. The grammar is extended to allow hex and binary integer literals, and all numeric literals may contain underscores for readability.