compile-time regex redux

Lars Ivar Igesund larsivar at igesund.net
Thu Feb 8 01:33:21 PST 2007


Bill Baxter wrote:

> 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

I very much agree with Bill here, because that will create true power to
such features in a much wider space. In addition, it was mentioned early on
which regex syntax should be used - and then we're onto the fact that
regex'es look different and operate different in different settings - some
are enhanced with this, and some with that (and many seems to think
std.regex is somewhat bad behaved). Having this easily implementable as
(compile time) libraries would allow for (or at least more likely inspire)
as many as users would feel is needed.  

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource & #D: larsivi
Dancing the Tango



More information about the Digitalmars-d mailing list