String reboot - (1a) incidental whitespace
Jim Laskey
james.laskey at oracle.com
Fri Apr 19 13:41:40 UTC 2019
Not sure I understand the issue here. The first line has no influence and is not affected by the indentation provided by the close delimiter influence. The example is a bit groggy. Maybe more interesting is that the both following work as an alternative pattern;
String m = """I won’t
get any alignment
(except maybe NL normalization)
""";
Result:
I won’t\n
get any alignment\n
(except maybe NL normalization)\n
String n = """I won’t
get any alignment
(except maybe NL normalization)""";
Result:
I won’t\n
get any alignment\n
(except maybe NL normalization)
> On Apr 18, 2019, at 2:08 PM, Liam Miller-Cushon <cushon at google.com> wrote:
>
> On Thu, Apr 18, 2019 at 8:52 AM Brian Goetz <brian.goetz at oracle.com <mailto:brian.goetz at oracle.com>> wrote:
>> I still find the restriction appealing for the opening delimiter, though. The argument is that having contents on the opening line seems likely to cause confusion, e.g.:
>>
>> String m = """ +--------+
>> | text |
>> +--------+""";
>>
>> Result of variable m under the current string-tapas prototype:
>>
>> ....+--------+\n
>> |..text..|\n
>> +--------+
>
> I think this is a restriction that is much more suitable to a _style guide_ than the language. Yes, users can get it wrong, but they’ll learn quickly. And, sometimes putting text on that first line is exactly what you want, such as in the case where you _dont_ want alignment to muck with your indentation. Putting non-blank text on that first line is effectively an opt-out:
>
> String m = “””I won’t
> get any alignment
> (except maybe NL normalization)
>
> ”””;
>
> I'm not sure that matches the behaviour of the current prototype, it doesn't seem to be considering the first line:
>
> String m = """I won’t
> get any alignment
> (except maybe NL normalization)
>
> """;
>
> Result of variable m
> I.won’t\n
> ....get.any.alignment\n
> ....(except.maybe.NL.normalization)\n
> \n
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20190419/df0afc15/attachment.html>
More information about the amber-spec-experts
mailing list