Any interest in keeping octal escape literals?

104 views
Skip to first unread message

Simon Ochsenreither

unread,
May 17, 2013, 9:01:18 AM5/17/13
to scala...@googlegroups.com
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

Haoyi Li

unread,
May 17, 2013, 9:29:21 AM5/17/13
to Simon Ochsenreither, scala-user
+1 from me; less unused features the better!



--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Simon Schäfer

unread,
May 17, 2013, 5:59:27 PM5/17/13
to scala...@googlegroups.com


On Friday, May 17, 2013 3:01:18 PM UTC+2, Simon Ochsenreither wrote:

If you have a use-case where you think octal escape literals are absolutely critical, please speak up!
 
I just implemented syntax highlighting for them in the IDE, do you want to tell me that all my work was for nothing?


Just kidding, have never used them in practice. I'm fine with killing them.

Eric Kolotyluk

unread,
May 17, 2013, 6:07:08 PM5/17/13
to scala-user
Please, please - make octal go away. It has been way too many years since I used a PDP-8

Cheers, Eric


--

Alex Cruise

unread,
May 17, 2013, 6:17:07 PM5/17/13
to Simon Ochsenreither, scala-user
In my codebase I have a single '\0' (i.e. ASCII NUL literal), and a bunch of Strings containing "...\x00...\x00...".  

So it's easy enough to work around, but a bit annoying that it's triple the length. :)

-0xe1a
Reply all
Reply to author
Forward
0 new messages