Raw string literals and Unicode escapes

Guy Steele guy.steele at oracle.com
Fri Feb 23 21:07:53 UTC 2018


+200.  Or even

    String s = “`" + `a raw string` + “`”;

It’s perfectly okay to use both kinds of string in one expression.
	
> On Feb 23, 2018, at 4:00 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> 
> 
> 
>> 
>> 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.
> 
> +100.  The RawSP trick is clever, but too much so.  There are ample simpler approaches for beginning/ending with BT:
> 
>     String s = BACKTICK + `a raw string` + BACKTICK;
>     String s = `` `a raw string` ``.trim();
> 
> These move the cognitive load on the user to the corner case, rather than landing it on the general case.
> 
> 



More information about the amber-spec-experts mailing list