From afe3cc209d4011f61ee5284895e6ab87f8a7a6ef Mon Sep 17 00:00:00 2001 From: NthPortal Date: Sat, 27 Jul 2019 23:38:34 -0400 Subject: [PATCH] SIP-NN: Support Binary Integer Literals --- .../2019-07-27-binary-integer-literals.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 _sips/sips/2019-07-27-binary-integer-literals.md diff --git a/_sips/sips/2019-07-27-binary-integer-literals.md b/_sips/sips/2019-07-27-binary-integer-literals.md new file mode 100644 index 0000000000..53a62a37e1 --- /dev/null +++ b/_sips/sips/2019-07-27-binary-integer-literals.md @@ -0,0 +1,31 @@ +--- +layout: sip +discourse: true +title: SIP-NN - Support Binary Integer Literals +--- + +**By: NthPortal** + +## History + +| Date | Version | +|---------------|--------------------------| +| Jul 27th 2019 | Initial Draft | + +Your feedback is welcome! If you're interested in discussing this proposal, head over to [this](https://contributors.scala-lang.org/t/pre-sip-binary-literals/3559) Scala Contributors thread and let me know what you think. + +## Proposal + +Support binary integer literals. For example, the binary literal `0b00101010` would have the integer value `42`. + +## Motivation + +Several other major languages support binary integer literals, including [Java](https://docs.oracle.com/javase/specs/jls/se12/html/jls-3.html#jls-3.10.1) (as of [Java 7](https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.1)), [Kotlin](https://kotlinlang.org/docs/reference/basic-types.html#literal-constants), [Python](https://docs.python.org/3/reference/lexical_analysis.html#integer-literals) and [Rust](https://doc.rust-lang.org/stable/reference/tokens.html#number-literals). + +## Interactions with Other Language Features + +Like other integer literals, binary integer literals support separators (`_`), which can greatly enhance the readability of larger values (e.g. `0b_1110_1101_1011_0111`). + +## Implementation + +The implementation of binary integer literals is quite simple, and can be found at .