[swift-evolution] Empower String type with regular expression
Dany St-Amant
dsa.mls at icloud.com
Tue Feb 2 21:06:43 CST 2016
> Le 2 févr. 2016 à 07:43, Patrick Gili <gili.patrick.r at gili-labs.com> a écrit :
>
> Dany,
>
> When you say "sub patterns", do you mean "capture groups"?
Looks like my sub-patterns/matches are in Perl parlance capture groups, but it seems that this may need support from the compiler. Tuple have fixed length (no support for variadic tuple), could not get arrays to work in switch case, enum cannot reuse same name with different set of associated value.
>> On Feb 1, 2016, at 10:43 PM, Dany St-Amant via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>
>>
>>> Le 31 janv. 2016 à 22:39, Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> a écrit :
>>>
>>>>
>>>> On Jan 31, 2016, at 8:32 AM, Patrick Gili via swift-evolution <swift-evolution at swift.org <mailto: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 sub patterns.
>>
>> I was seeing the sub patterns originally a bit like:
>> switch( string <match-op> regex) {
>> case .matches(_, "http", let port):
>> case .matches(_, let name, "8080"):
>> case .matches(_, "\\smb\ <smb://smb/>"):
>> }
>> but the comment about the pattern grammar make me of:
>> switch( string ) {
>> case regexp1: if ($0.1 = "http") { }
>> case regexp2:
>> }
>> Both have their uses
>>
>> Dany
>>
>>
>>> 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.
>>>
>>> -Chris
>>>
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto: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/20160202/e4701edf/attachment.html>
More information about the swift-evolution
mailing list