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

David Sweeris davesweeris at mac.com
Thu Apr 13 12:33:26 CDT 2017


On Apr 12, 2017, at 07:52, Thorsten Seitz via swift-evolution <swift-evolution at swift.org> wrote:

>> Am 12.04.2017 um 15:40 schrieb Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org>:
>> 
>> Hey folks,
>> 
>> 
>> We've revised the proposal again. The main difference: You no longer need an initial newline to enable indentation stripping, and stripping no longer removes that newline even if it is present. (Adrian Zubarev and I believe some others argued for this.) We
> 
> Hmm, not sure if I like these changes. I expect that almost all strings won't begin with a newline and a majority won’t end with a newline. The new design would require a leading backslash almost all the time and a trailing backslash often, which is ugly:
> 
> let mystring = "““\
>    text text
>    text text\
>    "““

(I think I've read the whole thread, but it can be easy to miss parts on the phone. I think this is different than what's already been discussed... sorry if this has already been suggested and I just missed it.)

What having this input:
> let mystring = "““
>    text text
>    text text
>    "““

yielding this output:
> text text
> text text

And this input:
> let mystring = "““/
>    text text
>    text text
>    /"““

yielding this output:
> 
> text text
> text text
> 

(Sorry about not putting in all the symbols... I don't know a way to type them on my phone)

If you think of the "/" as more of a "toggle whether the next character is escaped" instead of specifically "escape the next character", it makes sense (kinda)... or the outputs could be reversed. Either way, it allows easy access to both options and preserves the "paste-in block of text as-is" goal.

- Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170413/ae6c0e4d/attachment.html>


More information about the swift-evolution mailing list