See also: https://github.com/scala/bug/issues/3220
I would like to propose removing the special situation of unicode escapes, and make them “escapes just as any other escape”.
The two big issues I see with this are
This changes semantics of string literals, and I’m not sure what the correct migration path for this should be. Morally “”“tab\tseparated”"", and “”“tab\u0009separted”"" should be handled the same. At the moment, it’s not the same: the former has a the string “\t”, the later has a tab character. Breaking code is bad. The status-quo is also bad.
The same goes for the
I would also point out two further restrictions that this change would create: You used to be able to write a unicode escape in an identifier without needing to quote it with backticks. You lose this ability now. You either use backticks or just insert the literal character. Backticks have a special meaning in case statements though, and removing this functionality removes the ability to use unicode escapes in variable patterns, because using backticks in them makes them a stable identifier pattern.
I personally believe that people using unicode escapes in variable patterns, along with the people who write
\u0076\u0061\u006c\u0020\u0078\u0020\u003d\u0020\u0037 instead of
val x = 7 go the special hell, and their code breaking will be - at least in the grand (because eternal) scheme of things - the least of their worries, but for completeness sake I want to include it for discussion.
Is the general case worth it? I think so. What about breaking string literals and raw interpolations.