[swift-evolution] [swift-evolution-announce] [Review] SE-0168: Multi-Line String Literals

Greg Parker gparker at apple.com
Thu Apr 6 14:57:56 CDT 2017

> On Apr 6, 2017, at 12:35 PM, Joe Groff <jgroff at apple.com> wrote:
> Hello Swift community,
> The review of SE-0168 "Multi-Line String Literals" begins now and runs through April 12, 2017. The proposal is available here:
> https://github.com/apple/swift-evolution/blob/master/proposals/0168-multi-line-string-literals.md <https://github.com/apple/swift-evolution/blob/master/proposals/0168-multi-line-string-literals.md>

> Long strings are strings delimited by """triple quotes""" that can contain newlines and individual " characters without the need to escape them.

Are the set of backslash-escapes inside a long string identical to the set used in short strings? I assume that \" inside a long string is interpreted as an escaped double-quote; otherwise there would be no way to write """ inside a long string.

> To allow free formatting of the literal an indentation stripping operation is applied whereby any whitespace characters in front of the closing delimiter are removed from each of the lines in the literal. As part of this process any initial linefeed is also removed. This allows the developer to paste literal content directly into the string without modification. Some concern has been expressed about could introduce confusion if the prefixing indentation of each line does not contain the same whitespace characters, though this can be checked for by a compiler warning.

To clarify, is this the intended algorithm? 
    if the source code of the closing delimiter matches regex(\n\s+""") {
        collect the sequence of whitespace characters between the newline and the delimiter
        remove exactly that sequence of characters, if present, from the front of each source-code line after the line containing the opening delimiter
        if a line does not start with those characters, emit a warning

Greg Parker     gparker at apple.com     Runtime Wrangler

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170406/e283d48c/attachment.html>

More information about the swift-evolution mailing list