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

Adrian Zubarev adrian.zubarev at devandartist.com
Fri May 26 01:23:27 CDT 2017

Well /" "/ is far from being the queen of the beautiful syntaxes.

I summed up my thoughts in the following two gists:

David Hart and I are patiently waiting for post WWDC to see how the broader mass will react to the accepted changes. Furthermore, Chris Lattner said that he views WWDC betas as the way to figure out if proposals need to be fixed before release.

Adrian Zubarev
Sent with Airmail

Am 26. Mai 2017 um 08:02:28, Dave Yost via swift-evolution (swift-evolution at swift.org) schrieb:

Beauty is a top-three goal of Swift, so a proposal that is not beautiful should be rethought until it is.

1. """ is ugly.

2. Choosing syntax so as to pander to hacks in a few existing tools is the road to Ugly.

3. It’s inelegant syntax design for start and end delimiters to be identical, as for example ASCII quote marks are.[1]

4. Mirror image start and end delimiters are preferred, for example { and }.[1]

5. Escaping is ugly and preferably should not be necessary or even allowed.

Therefore, I propose, by example:

  let foo = 
    The indent of /"
        dictates indentation and must match 
    all indents through the "/

where an optional arbitrary identifier, for example “xx”, can be appended to both the open and the close quote delimiters to avoid the need for escaping the close quote delimiter. The identifier has no other significance in the program.

I further propose that /' and '/ should be used to delimit a string that is interpreted literally, including newlines except for the newline on the last line of the string.

In future, consideration should be given to the idea of following the /" delimiter by a set of space-separated flags to determine treatment of newlines, the escape character (so it doesn’t have to be backslash), use of interpolated strings, the use of escape characters, etc.


(I intended all single and double quotes in this message to be ASCII, not curly. If any are curly, then blame the macOS Mail app.)

[1].  I think Swift should allow delimiting strings with “curly” quotes, and they should nest. See 3, 4, 5 above.

swift-evolution mailing list
swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170526/ef6319c0/attachment.html>

More information about the swift-evolution mailing list