Text blocks / Multi-line string literals

Guy Bensky guyben at google.com
Tue May 14 08:48:27 UTC 2019


*From: *John Rose <john.r.rose at oracle.com>
*Date: *Mon, May 13, 2019, 7:51 PM
*To: *Stephen Colebourne
*Cc: *Amber dev

On May 13, 2019, at 4:41 PM, Stephen Colebourne <scolebourne at joda.org>
> wrote:
> >
> > On Tue, 14 May 2019 at 00:08, John Rose <john.r.rose at oracle.com> wrote:
> >>>> 3) The proposal is a little bit hostile to Markdown, because markdown
> >>>> relies on significant whitespace at the end of the line. I'd really
> >>>> like to see a new escape \s for \u0020 added at the same time as this
> >>>> feature to ensure there is a way out of the problem.
> >>>
> >>> That seems like a great idea to me…
> >>
> >> Just to rub everyone's nose in it again, \0020 is currently
> >> indistinguishable from a plain space.  So \s (which I support)
> >> would be a new escape for \040 and **NOT** for \u0020.
> >
> > Just to be clear, I'm proposing that \s is processed at the same time
> > as \t, \r and \n in the text block scheme, ie at the end. And at that
> > point it is fine to be a normal space.
>
> Right, so you intended \u0020 to mean "just a space in the code",
> as opposed from "a pretty ugly option for an escape sequence".
>
> If everyone on this list read it that way than some force (not all)
> is taken away from my insistence that we deal with \u order.
>
> But someone on the list might have read your suggestion as
> including a judgement that "\u0020 is not as nice an escape
> sequence as \s", rather than quietly positing that "\u0020 is
> not an escape sequence at all" (for string literals).  And lots
> of Java programmers will never quietly posit that at all; they
> will simply be mystified at the interaction between \u0020
> and blank stripping in text blocks.  An \s escape, coupled
> with a warning to stay away from \u0020, will steer them
> away from the problem.  And as I said, I would prefer to
> take even more decisive steps to reframe the interaction
> between \u escapes and strings.
>
> — John


I'll admit that I read it as "\u0020 is long and ugly, \s would be a nice
way of saying the same thing", so thanks for the clarification :)

How about just \ at the end of the line if we want trailing spaces?

A \ is currently an error if not followed by an escape character according
to the proposal, and many developers are used to seeing \ at the end of
lines.

We could have """
        Hello    \
        World""";
Translate to "Hello....\nWorld" (where the doors are placeholders for
spaces). This compared to """
        Hello   \s
        World""";

Which to me send less clear, and I don't like that since spaces are spaces
and others are \s.

On the other hand, people might confuse it with concatenation of lines, so


More information about the amber-dev mailing list