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
Support binary integer literals using 0b
, as in Java
#10656
Conversation
spec/01-lexical-syntax.md
Outdated
[‘L’ | ‘l’] | ||
decimalNumeral ::= digit {digit} | ||
hexNumeral ::= ‘0’ (‘x’ | ‘X’) hexDigit {hexDigit} | ||
binaryNumeral ::= ‘0’ (‘b’ | ‘B’) binaryDigit {binaryDigit} | ||
binaryDigit ::= ‘0’ | ‘1’ |
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.
binaryDigit ::= ‘0’ | ‘1’ |
Since there is no reminder of hexDigit, there probably shouldn't be one for binaryDigit
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.
I noticed digit was removed (because it's a char class?); and hexDigit was promoted to earlier section because of unicode escape. But maybe the rule of thumb should be "this is obvious so defer to the summary" as opposed to "chapter summary should be complete".
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.
I think that is a good rule of thumb
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.
thanks, I took both edits. The earlier hexdigit might be unnecessary, but the context is (TIL):
scala> val `\u0061\u0062\u0063` = 42
val abc: Int = 42
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.
Yeah I learned that as well a couple days ago, it's a cool feature in case you are restricted to ASCII, but still need to access some unicode-named methods
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.
LGTM
I was too lazy to change the Also, I wanted to avoid merge commit for trivial one-commit PR, but I'm not actually sure what the github button does. On dotty, they complained about |
So the text As it warns, the "author" was me; well, Foucault already told us that label is without stable meaning. Undoubtedly, I don't have a display name configured. Having the PR number in the comment header is handy; usually one must click thru to the commit to find where github displays the associated PR. Dotty must be using rebase and merge.
|
This comment was marked as resolved.
This comment was marked as resolved.
0b
, as in Java
FYI and thanks @NthPortal |
0b
, as in Java0b
, as in Java
Support binary integer literals. For example:
This language change was approved by the SIP (Scala Improvement Process) committee: SIP 42, https://docs.scala-lang.org/sips/binary-integer-literals.html
revival of #8275