One more coat of paint on octal literals

77 views
Skip to first unread message

Som Snytt

unread,
Feb 11, 2014, 5:18:38 AM2/11/14
to scala-internals

Interpolators using StringContext.treatEscapes process octal escapes.

Is that a bad thing because it is inconsistent with ordinary literals, or a good thing because people who like octals have an escape?  Pun intended.

scala> "\12\150\151\12"
warning: there were 4 deprecation warning(s); re-run with -deprecation for details
res0: String =
"
hi
"

scala> s"\12\150\151\12"
res1: String =
"
hi
"


The f-interpolator could warn at compile time, but s- is not macrotized.

scala> s"a\x"
scala.StringContext$InvalidEscapeException: invalid escape character at index 1 in "a\x"


`treatEscapes` sounds like a Disney vacation resort on Pleasure Island.

Simon Ochsenreither

unread,
Feb 11, 2014, 5:37:09 AM2/11/14
to scala-i...@googlegroups.com
No idea ... would have to think about it. Wasn't there some other corner case too lately? I keep forgetting to look into these things otherwise ...

Som Snytt

unread,
Feb 11, 2014, 6:22:40 PM2/11/14
to scala-internals
I think this was the corner case.  I forgot, too; so I leapt into action.

Not saying it's necessarily so, but:

https://github.com/scala/scala/pull/3511

One other use case is, you want to be able to take an arbitrary f"\15" and strip the f- without a big surprise.  Of course, in general, escapes are interpolator-specific, so that doc that says "I process the standard Scala escapes" could be updated accordingly.



On Tue, Feb 11, 2014 at 2:37 AM, Simon Ochsenreither <simon.och...@gmail.com> wrote:
No idea ... would have to think about it. Wasn't there some other corner case too lately? I keep forgetting to look into these things otherwise ...

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

Reply all
Reply to author
Forward
0 new messages