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

Xiaodi Wu xiaodi.wu at gmail.com
Thu Nov 23 14:20:57 CST 2017


On Thu, Nov 23, 2017 at 2:14 PM, John Holdsworth via swift-evolution <
swift-evolution at swift.org> wrote:

> I’m beginning to wish I hadn’t tied this proposal so strongly to regular
> expressions!
> It is indeed the wrong motivation. Even as a ten year veteran of Perl
> development
> I’m not sure we want to bake it into the language quite so tightly (isn’t
> a part of
> Foundation?) What would /regex/ represent - an instance of
> NSRegularExpression?
> Would the flags be pattern options or matching options? This is a whole
> other debate.
>
> For me the focus of raw strings was a sort of super-literal literal which
> has many
> applications. The r”literal” syntax has a precedent in Python and there
> seemed
> to be a syntactic gap that could be occupied but perhaps there are other
> alternatives
> we could discuss. It would be a shame to see ‘quoted strings’ be used for
> this however.
> I still live in hope one day it will be used for single character UNICODE
> values.
>
> Since what passes for a single character changes by Unicode revision--such
as whenever they get around to enumerating the permitted modifying
attributes of the poop emoji--it is quite impossible (and Swift's
`Character` doesn't attempt to) to enforce single-characterness at compile
time. We should put any such notions to rest up front.

> On 23 Nov 2017, at 19:10, Brent Royal-Gordon <brent at architechies.com>
> 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.
>
> 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 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/0d637bfe/attachment.html>


More information about the swift-evolution mailing list