compile-time regex redux
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Wed Feb 7 15:13:01 PST 2007
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.
> just being able to write like I can in D with compile time variables
> would be so much easier for me, and it would only require one template
> function instead of 35 to parse a simple string... for example.
>
> 1. A while back, I needed something very quickly to remove whitespace.
> it took me much less time with loops than I ever could have done with a
> regex. I want to be able to do the same in templates, if possible. I
> will be trying to reproduce later this, but I think that it will require
> a lot of templates.
> 2. what about building associative arrays out of a string? I have this
> function from existing code. It didn't take too long to write. I want to
> be able to write something like this in templates to build assoc arrays
> dynamically.
>
> I know I'm asking for a lot, but the way templates handle string are
> still kinda weird to me. Would string parsing in this sort of way be
> absolutely impossible with templates? I have not had good luck with it.
> Perhaps I missed something...
That would require functional-style programming - which, of course, also
seems hard before you learn it. So either way, we're hosed :o).
Andrei
More information about the Digitalmars-d
mailing list