JDK-8227870 - Escape Sequences For Line Continuation and White Space (Preview)
maurizio.cimadamore at oracle.com
Mon Sep 30 16:05:05 UTC 2019
On 30/09/2019 16:59, Brian Goetz wrote:
>> One is pedagogical; I think a world where single line strings are denoted by a single double quote, whereas multi line strings are denoted by triple double quotes is a relatively wimple world for the user to grok. This proposal effectively blurs the line between the two variants, as now you can (in the degenerate case where all lines in a text block ends with '\') express a single line string with a text block syntax - which I understand is the part of the goal, but…
> In some sense, the line was already blurry, because existing “single line strings” could have embedded \n newlines in them. IMO a better pedagogical model is “one dimensional vs two dimensional” string literals, but this may be a hard sell.
> In a world without \n, I think it would still be pedagogically simple: a “legacy” string literal is a single line of OUTPUT, and a text block can have multiple lines of output. The presense of \<nl> merely changes how the _input_ is organized.
> My conclusion is that, while the clamoring that inspired us to do this feature is “give us multi-line strings”, to the extent we continue to call them multi-line strings, we play into this confusion.
I don't disagree, but JEP 355 starts off with:
Add /text blocks/ to the Java language. A text block is a multi-line
string literal that avoids the need for most escape sequences,
automatically formats the string in a predictable way, and gives the
developer control over format when desired. This is a preview language
feature <https://openjdk.java.net/jeps/12> in JDK 13.
Now, I get the subtle distinction between multi-line in the source and
multi-line in the result value - but it's subtle, and I think the JEP
should at least be made clearer in that respect.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the amber-spec-experts