scsh-users
[Top] [All Lists]

New regexp substitution functions

To: shivers@lambda.ai.mit.edu
Subject: New regexp substitution functions
From: Alan Bawden <Alan@lcs.mit.edu>
Date: Sat, 19 Apr 1997 02:14:23 -0400
Cc: scsh@martigny.ai.mit.edu
Sender: Alan@lcs.mit.edu
   Date: 19 Apr 1997 00:21:07 -0400
   From: Olin Shivers <shivers@lambda.ai.mit.edu>

     - If an item is 'POST, the procedure recurses on the suffix string
       (the text from STRING following the match).  Including a 'POST in the
       list of items is how one gets multiple match/substitution operations.

Upon first reading, this seems completely unmotivated and totally random.
(Or perhaps I simply can't understand the description -- recurses how?)
But perhaps you are emulating some bit of Unix culture here that I'm not
familiar with?  I can't figure out why this procedure is called
".../global" either, so perhaps that's another part of the reason why this
seems so utterly random.

In all of your examples the 'POST is the -last- argument pased to
`regexp-substitute/global'.  What happens if it occurs somewhere in the
middle?  More than once?  And in fact, all of your calls to
`regexp-substitute/global', include 'POST as the last argument.  Hmm...

I guess the examples make it kind of clear what's going on here.  If there
isn't a 'POST anywhere, is `regexp-substitute/global' equivalent to plain
`regexp-substitute'?  I think that in the Lisp world we would give a
procedure like this a name like "map-regexp-matches" or something, and
perhaps there might be some lists involved somewhere.  This whole
`regexp-substitute/global' thing seems rather compulsively string oriented
-- can't you find some way to use any of the rest of Scheme to make this
nicer?

Of course I'm the guy who objects to the fact that sub-matches are
identified using numbers, and thus regular expressions have none of the
nice compositional properties that I was taught to appreciate by my
long-time exposure to Scheme.  So I can't really be expected to like adding
more procedures that buy ever more deeply into what I see as a flawed
framework.

(And I can't seem to interest anybody in addressing that issue either.
Seems like a good thesis topic for a bright undergraduate.  Anybody
listening?)

<Prev in Thread] Current Thread [Next in Thread>