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

Xiaodi Wu xiaodi.wu at gmail.com
Thu Nov 23 14:09:13 CST 2017


On Thu, Nov 23, 2017 at 1:12 PM, Brent Royal-Gordon via swift-evolution <
swift-evolution at swift.org> wrote:

> On Nov 23, 2017, at 11:15 AM, Chris Lattner via swift-evolution <
> swift-evolution at 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.
>

Can you explain why such interoperability would need _raw string literals_
as opposed to regex literals?


> 2. Code generation.
>

Can you elaborate on this?


> 3. Windows-style paths.
>

Sure, Windows-style paths use the backslash. But it's not a useful exercise
to enumerate all places where backslashes are used, but rather where
they're often used in _literals_. How often are you hardcoding
Windows-style paths? Wouldn't an ergonomic API accept the forward slash
also? Even many Microsoft-vended Windows utilities do so.


> 4. Doesn’t LaTeX use backslashes?
>

Again, not often you're hardcoding LaTeX literals. Let's not turn this into
an exercise in listing all places where you've seen a backslash used.


> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171123/f2eb162d/attachment.html>


More information about the swift-evolution mailing list