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

Chris Lattner clattner at nondot.org
Thu Nov 23 12:15:34 CST 2017



> On Nov 23, 2017, at 9:43 AM, John Holdsworth via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 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>
Hi John,

A lot of people (myself included) are interested in getting regex’s into Swift.  I don’t think there is consensus on how to do this, but I’m personally a fan of adding first class support with the classical /a[b*]c/ syntax.  Until we figure out that path forward for regex’s, I think they aren’t the right motivation for this proposal.

-Chris


> 
> 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
> _______________________________________________
> 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/20171123/bbd03629/attachment.html>


More information about the swift-evolution mailing list