compile-time regex redux

Bill Baxter dnewsgroup at billbaxter.com
Wed Feb 7 17:47:50 PST 2007


Andrei Alexandrescu (See Website For Email) wrote:
> kenny wrote:
>> Walter, I don't hate regex -- I just don't use it. It seems to me that 
>> to figure out regex syntax takes longer than writing quick for/while 
>> statements, and I usually forget cases in regex too...
> 
> I think this is an age-old issue: if you don't know something, you find 
> it harder to do things that way. The telling sign is that people who 
> know _both_ simple loops and regexes do use regexes, and as a 
> consequence are way more productive at a certain category of tasks.

Hmm.  More productive, probably.   Writing better code?  Not clear.  I 
would guess that in many cases the results are not as easy to maintain 
as non-regexp code.

Anyway, I think the question is whether compile-time regexp is really 
the right level of abstraction to be targeting.  Wouldn't it be 
infinitely better to have the compile-time code facilities be so good 
that you could just write a regexp parser as a compile-time D library?

I mean what is regexp, but a particular DSL?  If the new facilities are 
trying to make DSL's easier to create, regexp is a great target DSL.  So 
what compile-time language facilities do you need to implement an 
efficient and clean compile-time regexp library?

It would be nice if we could write more-or-less generic D code with a 
few compile time restrictions.  For instance you can write any function 
you want that takes only const values as arguments and returns a const 
value, and refers to only global const values and other such const-only 
functions.

--bb



More information about the Digitalmars-d mailing list