Builtin regex (Was: How to complex switch?)

bearophile bearophileHUGS at lycos.com
Tue May 17 13:46:32 PDT 2011


Stewart Gordon:

> I think D is going the right way on the whole by leaving regexps to a library.  Though 
> this does limit such possibilities as optimised regexp switches.

Leaving regexps to a library is an acceptable choice for D, or maybe even the best choice. In D even associative arrays are not so important as builtins, you just need literals for associative arrays.

On the other hand my experience shows me some other things are better as builtins (or partial built-ins), as tuples. I'd like unpacking syntax sugar for tuples, to be used inside foreach too, and as recently emerged in D.learn, some better cast for tuples (to allow conversion of slightly differently typed tuples, and structural typing).

Tuples are a general language construct, useful in many situations for many different purposes, they are _much_ more commonly useful than regex. I use some regex most Python scripts that processes lot of text, but I use tuples every 4-5 lines of code or less :-) And indeed, in Python too regexes are not built-in, while tuples are.

Bye,
bearophile


More information about the Digitalmars-d mailing list