Hi everyone,
in my quest to make Scala-the-language a bit smaller and simpler, I intend to deprecate and remove octal escape literals. The corresponding ticket is
https://issues.scala-lang.org/browse/SI-7292.
Some of the reasoning:
- Considering that we live in a Unicode world, the usefulness of
special syntactical shortcuts for characters between 0 and 255 is
greatly diminished.
- We already removed octal literals which are similarly confusing. I have never heard a single
person complaining (or even asking) about what happened with octal
literals. It's reasonable to assume that it will be the same for an even
more obscure feature.
- The parsing rules of octal escapes are unintuitive and misleading for unaware readers (e. g. it's not fixed-length like
\uXXXX, but stops accepting symbols as soon as it encounters some char it doesn't like. Example: \377 parses as one octal escape literal, \378 parses as an octal escape and 8 (because 8 is not octal, duh), 400 parses as an octal escape and a 0 (400 would be valid octal number, but–for whatever reasons–the literal is capped to the first 255 numbers)). - Those who want it, can implement it via string interpolation
- If one looks at some of our "competitors", they don't bothered to include it in the first place (and their literal syntax is even further removed from Java syntax).
- In general, we need less magic to happen between
what-the-developer-writes and what-the-compiler-sees. See the famous
let's-convert-unicode-escapes-in-comments puzzler for a similar case
where we are trying too hard to be Java. (Which–again–no other languages
even considers emulating.)
If you have never heard about them, all is fine.
If you have a use-case where you think octal escape literals are absolutely critical, please speak up!
Thanks,
Simon