From: mahler@socs.uts.EDU.AU (Daniel Mahler)
Newsgroups: comp.lang.scheme.scsh
Date: 5 Aug 1996 10:57:20 -0400
It seems to me that it would be more in the spirit of scheme
to specify regexps by forms rather than strings.
This would have 3 major benefits
1) it would simplfy writing functions that build regexps.
2) it would make regexps more readable (you could pretty print them)
3) it better reflects the abstract structure of regexps
4) AWK/Perl programers would have fits if they saw it.
The inplicit backquote convention used for
Scsh process forms would probably be appropriate.
Is there a reason why this is not the way it is done?
Several lisp/scheme implementations provide regexps
and they all seem to use AWK like syntax.
It's a good idea and a good question. I think there are several reasons
why people use the string syntax. First, it's easy -- there are pre-written
C libs out there that you can simply link against for instant support.
Second, it's compact. Scott Draves and I once spent a SF->Taiwan flight
working out an s-exp syntax for regexps, but we were never so thrilled
with it that we bothered to polish it off, sit down, and implement it. It's
a lot of work to implement an efficient regexp matcher.
However, I still think it's an interesting idea. But it won't happen unless
someone with real follow-through sits down, carefully figures out what the
design space is (e.g., note that Posix regexps have a lot of complicated bells
and whistles), works out a good syntax for a good design, and then carefully
implements a macro-expander/compiler/evaluator for the design. If he does
that well, he would make a mark. Anything less, and you have a half-solution.
It's a lot of work.
But I agree with your set of claimed advantages.
-Olin
|