Re: mbstrings

Jim Blandy (jimb@red-bean.com)
Thu, 16 Oct 1997 02:05:15 -0400

>But of /course/ Guile can do it automatically, too. :) Observe:
>
>(defmacro make-precompiled-regexp (reg)
> (if (string? reg)
> (make-regexp reg)
> `(make-regexp ,reg)))

Cute, but it won't work if you compile it, or freeze it. Something
like this violates R4RS's rules about literal pairs being immutable,
but:

(defmacro make-precompiled-regexp (reg)
(if (string? reg)
`(let ((cache '(#f)))
(if (not (car cache))
(set-car! cache (make-regexp ,reg)))
(car cache))
`(make-regexp ,reg)))

A real solution would use something like eval-when, which Guile
doesn't have...