Stefan Israelsson Tampe <stefan.ita...@gmail.com> writes: > (use-modules (srfi srfi-2)) > (use-modules (srfi srfi-1)) > > (define-curried (string-matches pattern string) > (and-let* ((match-struct (string-match pattern string)) > (count (match:count match-struct))) > (map (lambda(n)(match:substring match-struct n)) > (iota (1- count) 1)))) > > scheme@(guile-user)> (string-matches "([a-z])" "a") > $4 = ("a") > > > ,exp ((string-matches "([a-z])") "a") > $5 = ((lambda (string-871) > (let ((match-struct-876 > (string-match "([a-z])" string))) > (if match-struct-876 > (let ((count-880 (match:count match-struct-876))) > (if count-880 > (map (lambda (n-883) > (match:substring match-struct-876 n-883)) > (iota (#{1-}# count-880) 1)) > #f)) > #f))) > "a") > > And we see that string is not managed correctly. Is this a bug? I > can't understand why this is not treated as intended!
The problem is one that occurs when hygienic and non-hygienic macros are mixed. Here, and-let* is the non-hygienic one. Basically, in a hygienic macro, you carry around a bunch of context to allow you to refer to the right variable names. Then defmacro comes along, strips all that away, and uses the raw symbol names. We can fix and-let* to be hygienic, that's pretty easy, but I'm not sure what you can do about this in general. It's not like you can pass in the gensymed name, because that will break the way people who for some reason still right defmacros expect them to work. Dunno, maybe I'm just missing some insight here. -- Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"