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

Adrian Zubarev adrian.zubarev at devandartist.com
Thu Apr 13 12:41:35 CDT 2017


Was the / intended or did you meant to write \?

Personally I don’t think we’d need that behavior and can fallback to the natural way using a blank lines or explicit way using the \n character to solve that issue at the top or bottom of the multi-line string. The model I’m pushing already would support “paste-in block of text as-is”. :)

Glad to have you joining the discussion.



-- 
Adrian Zubarev
Sent with Airmail

Am 13. April 2017 um 19:33:42, David Sweeris via swift-evolution (swift-evolution at swift.org) schrieb:


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
_______________________________________________
swift-evolution mailing list
swift-evolution at swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170413/a8cf72a1/attachment.html>


More information about the swift-evolution mailing list