[Pitch v2]: Raw strings and SE-0200


(Erica Sadun) #1

@johnno1962 's SE-0200 was returned for revision.

Feedback

Core Team feedback made the following points:

  • The proposed r"…" syntax didn’t fit well with the rest of the language. The most-often-discussed replacement was #raw("…"), but the Core Team felt more discussion (as a pitch) is necessary.

  • The proposal itself leans heavily on regular expressions as a use case for raw string literals. Several reviewers remarked that the motivation wasn’t strong enough to justify the introduction of new syntax in the language, so a revised proposal will need additional motivating examples in other domains.

The feedback falls into two areas: What should this look like/be named in Swift and how can the proposal be enriched with motivating examples that go beyond regex.

Naming

In terms of naming, it’s critical to take both single and multi-line cases into account. Here is a contributor-adaptive poll on what to name this feature. You can add naming or vote for an already-listed name. Please add examples of use in this thread.

Use Case

In terms of motivating examples, it would help to collect use-cases from those who intend to use the feature outside of regular expressions.

My use-cases include:

  • Metaprogramming, specifically code producing code for a number of utilities I maintain.
  • Pedagogy, which often incorporates code snippets
  • Linting

Additional cases include Windows paths, incorporating quoted dialog, grammars, and of course regex.

I’ve set up a second adaptive poll to collect further use-cases. Please add details and examples in this thread.

Please do not use this thread to discuss the merits of whether this proposal should move forward or be rejected. Instead, focus on naming and use-case collection. This will allow the proposal to be revised and stabilized so it will not need updates during any future review process. Thank you.