JDK-8227870 - Escape Sequences For Line Continuation and White Space (Preview)
maurizio.cimadamore at oracle.com
Mon Sep 30 15:50:49 UTC 2019
On 30/09/2019 16:36, Jim Laskey wrote:
> In line.
>> On Sep 30, 2019, at 12:29 PM, Maurizio Cimadamore
>> <maurizio.cimadamore at oracle.com
>> <mailto:maurizio.cimadamore at oracle.com>> wrote:
>> 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...
> And String s = "aa\nbb\ncc\n" is truly single line? I think they are
> just the same thing wearing different clothes.
I see where you are coming from. While I'm not necessarily opposed, I'd
be curious to see if this add-on would have repercussions on how the
text block feature is reasoned about by programmers, especially ones
coming to Java for the first time.
>> 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.
> This is a readability issue in the edits. It's actually
> "red....\ngreen..\nblue...\n". I'll fix.
Question - can `/s` appear _before_ the end of a line in a text block?
If so, what happens?
>> 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.
>>> Please review and comment here.
>>> -- Jim
More information about the amber-spec-observers