RFR: Multi-line String Literal (Preview) JEP [EG Draft]

Brian Goetz brian.goetz at oracle.com
Thu May 9 22:21:37 UTC 2019

> One possibility is language enforcement: at the part of the processing of a multiline string where whitespace is stripped off to the left of the rectangle, it could be an error if that leading whitespace is not “spelled the same” on all lines from which it is being stripped.  I lean toward recommending this.

I see the logic here, but it also makes me a bit uncomfortable.  Our story is that indentation-stripping is done by a JDK method (String::stripIndent), and that the language behavior is specified in terms of the library behavior.  (This is essential if we want to allow users to opt out, do some manipulation on the un-aligned form, and then perform alignment — the language and library behavior must be, er, aligned.). 

We could surely make String::stripIndent throw when you present it a mixed-whitespace string, but do we really want this?  I would prefer that stripIndent be a total function on strings, even if it has to produce ugly output when given ugly input.  

More information about the amber-spec-observers mailing list