[raw-strings] Indentation problem
Brian Goetz
brian.goetz at oracle.com
Mon Feb 5 17:37:31 UTC 2018
> But, wait! We don’t even have to add that to Java, because we have a
> string concatenation operator, `+`:
For years, this was exactly my answer regarding "Why don't we have
multi-line strings." What turned me around was Jim convincing me that
the problem was not the inability to express a multi-line string (which
we've been able to do since day 1, as you point out), but the
higher-level issue -- the accidental friction of embedding a (small)
foreign document (JSON snippet, SQL snippet, etc) in a Java program
without Java's string proclivities mangling the embedded document.
Multi-line is one aspect of this, but if this were all there was, I'd
still be with you on "we already have this, let's move on." The bigger
aspect is intrusion on things like regexes (lots of double-escaping,
since \ is used extensively by regex), which are not even multi-line,
and the introduction of errors into embedded documents while trying to
turn them into something the Java lexer will accept.
So, I prefer to think of this feature not as "multi-line strings" or
even as "raw strings", but "embedded strings"; things that look like
strings from the outside but look like whatever you want them to on the
inside.
More information about the amber-spec-experts
mailing list