[swift-evolution] Empower String type with regular expression

Sune Foldager cyano at me.com
Mon Feb 1 09:56:15 CST 2016


On 01 Feb 2016, at 04:39, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 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 sub patterns.

These two things seem somewhat orthogonal to me, but I am also much more excited about what you propose; many languages have regex literals, and that’s great, but allowing them in pattern matching with variable binding and efficient parallel execution is much rarer.

Standard regex literals isn’t too important for Swift, IMO. Writing /…../ or Regex(‘…..’) isn’t that different, really. Regex could be initialised from strings as well, making the difference even smaller.

-Sune

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160201/a3d07c75/attachment.html>


More information about the swift-evolution mailing list