[swift-evolution] Empower String type with regular expression
gili.patrick.r at gili-labs.com
Mon Feb 1 08:56:34 CST 2016
In addition, I would like to consider the direction suggested by Chris. I don't think something like Swift Verbal Expressions works well with this direction. However, I could be wrong. If someone can illustrate how to do this, I'm open the idea.
> On Feb 1, 2016, at 5:22 AM, Gwendal Roué via swift-evolution <swift-evolution at swift.org> wrote:
>> Le 1 févr. 2016 à 04:48, John Randolph via swift-evolution <swift-evolution at swift.org> a écrit :
>>> On Jan 31, 2016, at 7:39 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>>>> On Jan 31, 2016, at 8:32 AM, Patrick Gili via swift-evolution <swift-evolution at swift.org> wrote:
>>>> There have been several threads that have discussed the notion of a regular expression literals. However, I didn't see anyone putting together a formal proposal, and hence I took the liberty to do so. I would appreciate discussion and comments on the proposal:
>>> I am +1 on the concept of adding regex literals to Swift, but -1 on this proposal.
>>> Specifically, instead of introducing regex literals, I’d suggest that you investigate introducing regex’s to the pattern grammar, which is what Swift uses for matching already. Regex’s should be usable in the cases of a switch, for example. Similarly, they should be able to bind variables directly to subpatterns.
>>> 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.
>> Perl 6’s regex implementation looks like a logical progression of the grep style as we’ve come to know it over the years, but I’d really like to see Swift go with something like the Verbal Expressions approach.
>> All the power is there, but it’s far more readable.
> It depends who is the reader.
> When the reader is an expert, `VerEx().startOfLine().then("http")` is much less readable than /^http/. It’s all about calling a spade a spade, and a regular expression, a regular expression. See https://swift.org/documentation/api-design-guidelines/#use-terminology-well <https://swift.org/documentation/api-design-guidelines/#use-terminology-well>.
> Swift should aim at expert features: the great open source community will provide libraries as SwiftVerbalExpressions. Expert features don’t have to be complex. they just need to be comprehensive and well-exposed.
> In a related topic, I much prefer a Swift wrapper for a SQL database that gives me *optional* sugar on top on a *solid* support for SQL.
> Gwendal Roué
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution