RFR: JDK-8198986 - 3.10.7: Raw string literals

Stephen Colebourne scolebourne at joda.org
Tue Mar 13 22:59:07 UTC 2018


On 7 March 2018 at 21:41, John Rose <john.r.rose at oracle.com> wrote:
> One problem in the examples:
>
> ````````````
> Hello, world
> ````````````    // the twelve characters H e l l o , SP w o r l d

Using multiple backtick repetition really is a poor choice as an
example like this shows. What if you have 12 backticks at the start
but 13 at the end? While the compiler will catch it (at the expense of
a weird rule that raw string literals can't start/end with a
backtick), your eye cannot. Adding a language feature that your eye
can easily get wrong is a mistake (and what a boring/hellish Java
certification question).

Java also has no other feature where unlimited repetitions are used to
indicate something important.

Somewhere along the line this feature has simply been over-thought.
Raw strings need to be a *simple* form that copes with most use cases.
It should use a single well-defined start/end that is not subject to
unlimited repetition. It would be *much* simpler to have a single
backtick at the start/end with two backticks internally acting as an
escape. It also eliminates the weird no backtick at start/end rule.

`` = "" (empty)
``` - compile error
```` = "`" (single backtick)
```AAA``` = "`AAA`" (AAA surrounded by backticks)

Simple, straightforward, and far more in line with expectations (and
much easier for pasting code in/out).

Please can we stop the backtick repetition craziness now!

Stephen


More information about the amber-dev mailing list