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

Adrian Zubarev adrian.zubarev at devandartist.com
Thu Apr 13 13:25:23 CDT 2017


Sure thing, everyones opinion is welcome and helps fine tuning the model.

Here is a quick illustration of the model I’m pushing.



-- 
Adrian Zubarev
Sent with Airmail

Am 13. April 2017 um 20:02:44, David Sweeris (davesweeris at mac.com) schrieb:


On Apr 13, 2017, at 10:52, Adrian Zubarev <adrian.zubarev at devandartist.com> wrote:

I don’t think it’s a good idea to add optionally character before the closing delimiter, because it could confuse the reader of the code on how exactly the actual string lines above will be stripped.

My personal vision remains as the following example:

// 1)
"""
Line_1
Line_2
"""

// result for 1)
"Line_1\nLine_2"

// 2)
"""

Line_1
Line_2
"""

// result for 2)
"\nLine_1\nLine_2"

// 3)
"""
Line_1
Line_2

"""

// result for 3)
"Line_1\nLine_2\n"

// 4)
"""

Line_1
Line_2

"""

// result for 4)
"\nLine_1\nLine_2\n"
This is the natural approach, alternatively you’re free to use directly \n instead a blank line.


I think I'm inclined to agree... I'm just trying to think of ways to make those who don't agree happy as well. Of course, as you pointed out, that necessarily complicates things, which is itself something to consider.

Fortunately, we can add the syntax (or something else equally simple) to flip the leading/trailing newline stripping behavior later, if it becomes necessary.

- Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170413/2d320cc0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multi-line-string-literal.png
Type: image/png
Size: 16134 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170413/2d320cc0/attachment.png>


More information about the swift-evolution mailing list