[swift-evolution] [Pitch] Raw mode string literals

John Holdsworth mac at johnholdsworth.com
Thu Nov 23 05:25:05 CST 2017


Hello S/E,

I’d like to put forward a perhaps rather banal change to the Swift lexer
primarily intended to make entering regular expression patterns easier.

https://github.com/DoubleSpeak/swift-evolution/blob/master/proposals/NNNN-raw-string-escaping.md <https://github.com/DoubleSpeak/swift-evolution/blob/master/proposals/NNNN-raw-string-escaping.md>

With a raw literal a string prefixed by “r” the \ character would have no
special role at all and be processed like any other character i.e.

    r"\n\(var)\n" == "\\n\\(var)\\n"

    r"\?\y\=" == "\\?\\y\\="

    r"c:\windows\system32" == "c:\\windows\\system32"

    r"""
        Line One\
        Line Two\
        """ == "Line One\\\nLineTwo\\"

I had considered another version of the proposal where known escapes
were still processed but it proved too difficult to reason exactly what was
contained in the string.

There is a example toolchain available for testing:

http://johnholdsworth.com/swift-LOCAL-2017-11-23-a-osx.tar.gz <http://johnholdsworth.com/swift-LOCAL-2017-11-23-a-osx.tar.gz>

Can we shepard this minor additive change into Swift 4.1?

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171123/1b27074f/attachment.html>


More information about the swift-evolution mailing list