[swift-evolution] [Pitch] Raw mode string literals
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>
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.
> 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"
> 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?
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution