Raw string literals and Unicode escapes

Alex Buckley alex.buckley at oracle.com
Wed Feb 14 22:42:50 UTC 2018

On 2/14/2018 1:48 PM, John Rose wrote:
> P.S. I posted another version that takes a slightly different
> tack on the restriction of "cannot begin with a backquote".
> It basically lifts the whole design of Markdown code quotes.
> http://cr.openjdk.java.net/~jrose/jls/raw-string-pages-v5.pdf

The inclusion of RawSP means that you are fully delivering on your 
trailer from Jan 30: "Spoiler: I think I can prove that Markdown code 
quoting is appropriately minimal in its design, in a way Jim's is not."

Let me first recognize the power of RawSP in lifting TWO restrictions: 
cannot begin with a backtick, and cannot end with a backtick:

   String s = ``Hi `Bob```;       // Error, unbalanced delimiters
   String s = ``Hi `Bob`` + "`";  // OK
   String s = `` Hi `Bob` ``;     // OK with RawSP trick

However, since the JEP's goal is to allow copy-paste of arbitrary text 
without interpretation, I think the RawSP trick of assigning meaning to 
whitespace is out of place. To most people, the raw string literal:

   ` and `

denotes a perfectly good five-character string that will probably be 
inserted between two other strings. Explaining that, no, it's really a 
three-character string will not be popular.

Also, the inclusion of RawSP makes the lexing of RawStringLiteral 
ambiguous, since RawStringBody allows opening and closing whitespace. No 
doubt this can be fixed with rules involving "If the first character 
after RawSP is a backtick ...", but now being like Markdown is getting 


More information about the amber-spec-observers mailing list