[swift-evolution] Empower String type with regular expression
Vincent Esche
regexident.mailinglists at gmail.com
Mon Jan 4 08:52:12 CST 2016
There is actually a Rust crate doing exactly that: https://github.com/jneem/regex-dfa
Rust however has powerful compile-time macros, enabling this, which Swift doesn’t (yet?).
> On 04 Jan 2016, at 02:53, Austin Zheng via swift-evolution <swift-evolution at swift.org> wrote:
>
> +1 on first-class regex support/pattern matching on regex patterns.
>
> There was a thread a while ago discussing compile-time code generation, and if I recall correctly one of the stated use cases was 'compiling'/'building' (don't know the real terminology) regex literals at compile-time. Is there a bigger overall vision for this sort of feature, or would it be better to just focus on better regex support?
>
> Best,
> Austin
>
> On Sun, Jan 3, 2016 at 1:35 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> On Jan 1, 2016, at 4:44 PM, John Joyce via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> It is also probably worth burning first-class language support for regexes. This would allow specifying variable captures inline in the pattern, would allow flexible syntax for defining regexes, support powerful extensions to the base regex model (e.g. Perl 6 style), and would provide better compile-time checking and error recovery for mistakes.
>>>
>>> -Chris
>> I know this is an old thread already, but this sure would be one of the major breakout pieces of functionality.
>> If Swift had native regular expressions, without all the noise you see in the Objective-C API that exposes ICU regular expressions, the adoption rate would be huge.
>> If they were *truly* native, as in somebody sat down and built an NFA (or one of the fancier approaches that mixes with DFA) state machine, Swift's best-in-class Unicode support would and could result in amazing things.
>> It'd boost the scripting use of Swift tremendously and seal the deal as a server side language.
>
> Totally agreed. switch on a string with a bunch of regexes being matched should turn into a parallel state machine, just like a lexer :-)
>
> -Chris
>
>
>
> _______________________________________________
> 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>
>
>
> _______________________________________________
> 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...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160104/c7b28686/attachment.html>
More information about the swift-evolution
mailing list