String reboot (plain text)

Fred Curts fred.curts at icloud.com
Mon Mar 18 11:43:56 UTC 2019


Let's do a thought experiment: If Java literally adopted Swift's string literals, there would be no old/new or raw/non-raw distinctions. There would just be single line and multiline strings with customizable string delimiters. (Swift's "raw string" terminology is unfortunate.) A truly raw string literal would be easy enough to simulate with a highly customized string delimiter (which, importantly, also gives a highly customized escape sequence) and unindented closing delimiter. String interpolation could be added later (even for single line strings) because it's based on the existing (now customizable) escape sequence. What's not to like here?

In my view, Swift demonstrates that customizable string delimiters (which also affect escape sequences) make a raw/non-raw distinction unnecessary. (Note that this has nothing to do with coupling orthogonal features.) I have yet to hit a case where Swift's string literals prove inadequate in practice.

-Fred

On Wed, Mar 13, 2019 at 12:57 PM Brian Goetz <brian.goetz at oracle.com> wrote:

> To the “indent is good enough” point: Auto reflow is a disaster when
> applied to mixed spaces and tabs; while in general one should avoid this, I
> cannot rule out the possibility that someone might actually want to embed
> such a snippet; in that case, truly raw strings are an option.  If we take
> away truly raw, now they just have two bad approximations.



More information about the amber-spec-comments mailing list