Wrapping up the first two courses
Kevin Bourrillion
kevinb at google.com
Fri Apr 26 00:19:02 UTC 2019
I'm sure I'm not saying anything totally new in the following, but this is
my summary of why I don't see the necessity of any explicit opt-out like \-.
Suppose I write this:
String s = """
some
lines go here
""";
And suppose I have learned to picture a rectangle whose left edge is the
left edge of the ending delimiter.
Well, once I'm already picturing that rectangle based on the delimiter,
then clearly if I leave the delimiter alone, that leaves the rectangle
alone. I can change to
String s = """
some
lines go here
""";
... to insert two spaces before `some`, and I can further change to
String s = """
some
lines go here
""";
... to also insert two spaces before `lines`.
What is notable to me is that at no point did I ever change from *one kind* of
string literal to *another*. There is no feature that I opted in or out of
-- because there just doesn't need to be. That to me is a clear and
compelling win for simplicity.
It's entirely possible this was all 100% clear already, in which case sorry!
On Thu, Apr 25, 2019 at 4:30 PM Liam Miller-Cushon <cushon at google.com>
wrote:
> On Thu, Apr 25, 2019 at 8:56 AM Brian Goetz <brian.goetz at oracle.com>
> wrote:
>
> > For 2/3, here’s a radical suggestion. Our theory is, a “fat” string is
> > one that is is co-mingled with the indentation of the surrounding code,
> and
> > one which we usually wish the compiler to disentangle for us. By this
> > interpretation, fat single-line strings make no sense, so let’s ban them,
> > and similarly, text on the first line similarly makes little sense, so
> > let’s ban that too. In other words, fat strings (with the possible
> > exception of the trailing delimiter) must exist within a “Kevin
> > Rectangle.”
> >
>
> +1
>
> I thought Jim presented a good case for an exception for the trailing
> delimiter, but otherwise disallowing single-line 'fat' strings (single-line
> multi-line strings?) seems to mostly have upside.
>
> For 4 (opt out), I think it is OK to allow a self-stripping escape on the
> > first line (e.g., \-), which expands to nothing, but suppresses
> stripping.
> > This effectively becomes a “here doc”.
> >
>
> This seems OK to me too, but is there good return on complexity? Closing
> delimiter influence can also be used to opt out of stripping. Are there
> enough use-cases to justify a second opt-out mechanism? And does it have to
> be decided now, or could it be added later?
>
--
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20190425/38fee3be/attachment.html>
More information about the amber-spec-experts
mailing list