[Pitch] Raw mode string literals

I eh, literally just ran into a situation where this feature would have been super useful:

Someone sent me a JSON string with “\” in it. I needed to plug it into the UI logic to test something but I had to escape the “\”s again to make JSONSerialization happy.

A raw string literal syntax, especially when combined with multi line literals, would be very helpful.

That said, how/whether this syntax compose with multi line literal, interpolation, and the potential regex literal Chris mentioned earlier, deserves thorough consideration and deliberation.

Daniel Duan

···

Sent from my iPhone

On Nov 23, 2017, at 11:12 AM, Brent Royal-Gordon via swift-evolution <swift-evolution@swift.org> wrote:

On Nov 23, 2017, at 11:15 AM, Chris Lattner via swift-evolution <swift-evolution@swift.org> wrote:

Until we figure out that path forward for regex’s, I think they aren’t the right motivation for this proposal.

1. Even in our shining pattern matching future—a future which I, for one, am eager to hasten—we will still need to interoperate with NSRegularExpression and other Perl 5-compatible regex engines.

2. Code generation.

3. Windows-style paths.

4. Doesn’t LaTeX use backslashes?

5. Etc.

I think the Motivation section undersells this proposal. Regexes are a strong short-run use case, but in the long run, we’ll need this for other things. In both cases, though, raw literals will be a useful addition to the language, improving the clarity of Swift code much like multiline literals already have.

--
Brent Royal-Gordon
Sent from my iPhone

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution