Alex Shinn wrote:
> Generally, I'm a huge advocate of sexp's over other syntax in almost
> every case. But the above example looks about as simple as you can hope
> for in Perl.
I deliberately chose a simple example. I still think SREs have advantages,
but either way, I'm happy to just avoid Perl, which is what I used to use
for this kind of task, when nothing other than perhaps awk would easily do
the trick. It's not so much that Perl regexps are bad - it's the rest of
An exercise which might be interesting would be to work through Larry Wall's
Apocalypse 5 (http://www.perl.com/pub/a/2002/06/04/apo5.html) and see how
many of the regexp-specific problems it mentions are addressed, or at least
are addressable, by SREs. I get the sense that Perl is rushing headlong in
the "piling feature on top of feature" direction which Scheme has
> The SRE version has about the same number of conceptual
> elements, but is much more verbose and "looks" nothing like what you're
> trying to match.
I'm all in favor of the template argument, that the shape of the program
should match the shape of the data, but I don't see traditional string
regexps as meeting this criterion, most of the time.
I like structured regexps. Making interpolated strings *look* structured
isn't quite the same thing - for example, the way you lay out the text isn't
necessarily the way the parser will understand it.
To some extent, it may be a taste thing, but that's only because of the
issue you mention, which is that regexps in generally can only take you so
far. So SREs may not be really necessary, given the relative simplicity of
the application domain, but for me, they're nice to have.
> I'd like to see an example where SRE really shines
> over conventional regexp syntax.
Your criteria are different than mine. I think SREs do shine, for many of
the same reasons that I like sexp syntax in other areas.