[Snow-users-list] high-priority snow packages and package naming

Julian Graham joolean at gmail.com
Sat Sep 15 17:21:57 EDT 2007

> You better understand that this is such an open-ended
> opinion swap that no matter what answer I give, betting
> money would likely be that my answer is bullshit.

Yes, fair enough.

> Every regexp engine in the world -- Perl, Posix, whatever -- will
> give you its own best performance for the subset "true regular
> expressions" and, essentially, every single one of them will give
> the exact same results for the same inputs and patterns.
> Here is something whose performance would not suck:
> a portable Scheme library that assumed fast, native
> true regular expressions, but that then added all the fancier
> features, as in Dorai's thing or Shiver's thing.

Right.  So, working with the assumption (which I think is kind of
reasonable) that most of the Scheme platforms that Snow supports are
really just wrappers for a native POSIX implementation that present
said implementation in some way consistent with the mores of that
platform, I went through the list looking for a reasonable common
subset of basic regexp functionality.  So here's a proposal for a Snow
regexp API --

(regexp-compile str) ;; Compile a string into a regexp object

;; Return a match object for a compiled regexp and a string,
;; (optionally) using explicit substring addressing
(regexp-match pattern str [start] [end])

;; Perform regexp replacement on a string using a compiled
;; regexp -- replacement will first be inserted after first-match
;; and will be inserted for no more than max-matches matches.
;; [not sure if this is the right way to present this function...]
(regexp-replace pattern str replacement [first-match] [max-matches])

(regexp? pattern) ;; type checking for compiled regexp objects

(regexp-match? match) ;; type checking for match structures

;; the number of matches in a match structure
(regexp-match:count match)

;; the start index of match n
(regexp-match:start match [n])

;; the end index of match n
(regexp-match:end match [n])

What do people think?

More information about the Snow-users-list mailing list