String reboot - (1a) incidental whitespace

Brian Goetz brian.goetz at oracle.com
Tue Apr 16 21:28:21 UTC 2019


So let's move on to the follow up question.  If you replace concatenated 
strings -- which can have exactly the right amount of indentation:

     String s =
         "public class Foo { \n" +
         "    void m() { }\n" +
         "}";

with multi-line strings:

     String s = """
         public class Foo {
             void m() { }
         }
         """;

you've gained one thing (dropping the concat and escapes), but have 
inherited a bunch of additional incidental leading whitespace.  And 
we've talked about two paths for that, the implicit one (where we 
auto-align, in the absence of reasons not to), and the explicit one:

     String s = """
         public class Foo {
             void m() { }
         }
         """.align();

What can your data tell us about how often you care about incidental 
whitespace, and how often you'd be saying ".align()"?

On 4/16/2019 4:50 PM, Liam Miller-Cushon wrote:
> On Fri, Apr 12, 2019 at 8:39 AM Jim Laskey <james.laskey at oracle.com 
> <mailto:james.laskey at oracle.com>> wrote:
>
>     Do you have numbers from your RSL survey for, of all string
>     expressions that are candidates for translation to a multi-line
>     string literal, what percentage contain no escapes other than
>     quotes and newline?
>
>
> Based on our data roughly 1 in 85 candidates for multi-line string 
> literals contain non-trivial escapes.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20190416/225a5b1b/attachment.html>


More information about the amber-spec-experts mailing list