[swift-evolution] Empower String type with regular expression

Chris Lattner clattner at apple.com
Thu Feb 11 16:30:12 CST 2016

> On Feb 7, 2016, at 2:13 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> Further, I highly recommend checking out Perl 6’s regular expressions.  They are a community that has had an obsessive passion for regular expressions, and in Perl 6 they were given the chance to reinvent the wheel based on what they learned.  What they came up with is very powerful, and pretty good all around.
> As someone who learned to argue about language design on perl6-language, you have my interest. :^)
> How far do you want to go here?

Honestly, I don’t know.  I haven’t had much time to think/fantasize about this since it is clearly outside the scope of what we can do in Swift 3.  I’d love to tackle regex’s in Swift 4, though it is too early to tell what we’ll be able to tackle there (depends on what all we get done in Swift 3).

> In the small, Perl 6 redesigned regex syntax to remove certain syntactic hacks and make more common operations more accessible; in the medium, they introduced extensibility and reusability with named rules; in the large, they made grammars of named rules a first-class language feature; and in the very large, they turned the parsing of Perl itself into a Perl grammar you could subclass and modify for metaprogramming. #1 and #4 are very different propositions.

I don’t care about #4 at all, but I’m very interested in 1-3.  My interest in turning regex’s into a first class language feature (instead of, e.g., a new string literal type) is that we can get better compiler error recovery, IDE support, better integration with pattern matching, and generally “unlimited” integration with the rest of the language.


More information about the swift-evolution mailing list