diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm index e522f54..70463a5 100644 --- a/module/ice-9/psyntax.scm +++ b/module/ice-9/psyntax.scm @@ -155,6 +155,10 @@ (eval-when (compile) (set-current-module (resolve-module '(guile)))) +(define *macro-lookup* (make-fluid)) +(fluid-set! *macro-lookup* + (lambda x (error "not in a macro evaluation context"))) + (let () (define-syntax define-expansion-constructors (lambda (x) @@ -1304,8 +1308,12 @@ (syntax-violation #f "encountered raw symbol in macro output" (source-wrap e w (wrap-subst w) mod) x)) (else (decorate-source x s))))) - (rebuild-macro-output (p (source-wrap e (anti-mark w) s mod)) - (new-mark)))) + (with-fluids ((*macro-lookup* + (lambda (e) (lookup (id-var-name e w) + r mod)))) + + (rebuild-macro-output (p (source-wrap e (anti-mark w) s mod)) + (new-mark))))) (define expand-body ;; In processing the forms of the body, we create a new, empty wrap. @@ -2398,10 +2406,14 @@ (lambda* (x #:optional (m 'e) (esew '(eval))) (expand-top-sequence (list x) null-env top-wrap #f m esew (cons 'hygiene (module-name (current-module)))))) + (set! syntax-binding-info + (lambda (x) + ((fluid-ref *macro-lookup*) x))) (set! identifier? (lambda (x) (nonsymbol-id? x))) + (set! datum->syntax (lambda (id datum)