[swift-evolution] multi-line string literals.

Uli Kusterer kusterer at orangejuiceliberationfront.com
Tue Apr 26 20:53:23 CDT 2016

On 26 Apr 2016, at 08:04, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> B) Introduce a modifier character that requires a more complex closing sequence to close off the string, see C++ raw string literals for prior art on this approach.  Perhaps something like:
> 	 Rxxx”look “ here “ I can use quotes “xxx

Can you clarify how this is different from heredoc? Because really, whether I write <<DELIMITER


doesn't seem to make much of a difference.

FWIW, what I did in Hammer (my HyperCard clone's programming language) was to simply support several different international quotes. So you had standard inch signs:


which were extended to support line breaks. I also offered:


All these do is behave essentially like the inch signs, but require you to quote a different character. So if you're Swiss or French, you'd stick with inch signs. If you're English and not that good at typography, you'd use guillemets. If you're writing French HTML, you'd go with the typographic quotes. It solves pasting in longer text as long as it doesn't contain too many different characters, you can use several different ones on one line, the optimizer doesn't car which you use and will merge the actual text data of consecutive strings.

Since most larger documents are better included as separate resource files instead of pasted into the code, this covers common uses of multiline or regexes. Since such text won't be very long it's also not as bad to ignore indentation (and if you don't like the look, that's something that can be fixed by the editor applying an indent).

-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."

More information about the swift-evolution mailing list