JDK-8227870 - Escape Sequences For Line Continuation and White Space (Preview)

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Sep 30 15:29:39 UTC 2019

in general I see where the enhancements are coming from - but I do have 
some comments.

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...

The other perplexity is on the use of \s with text blocks; I don't get 
why the output in your example ends up being:

red<one space><new line>green<one space><new line>blue<one space><blue line>

Why is the space at the left of the '\s' being ignored? In fact, '\s' is 
the _only_ thing you can put in that place that will cause the previous 
space to be ignored and dropped on the floor, which makes me 
uncomfortable. I think that, to get the output you want, '\s' should be 
close to the end of red/green/blue - if, on the other hand, if you add 
space and _then_ you add a '/s', I don't think we should treat this 
differently from adding space and then some _random_ character - in 
which case all the space in between will be preserved.


On 30/09/2019 12:45, Jim Laskey wrote:
> During the discussion on Text Blocks, several of you stated a need for a line continuation construct. I have since created a CSR to propose the creation of two new escape sequences: \<line terminator> and \s.
> 	https://bugs.openjdk.java.net/browse/JDK-8227870
> Please review and comment here.
> Cheers,
> -- Jim

More information about the amber-spec-experts mailing list