[plt-scheme] defines and modules inside macro

From: Ivanov Alexey (aalleexx7 at yandex.ru)
Date: Thu Nov 12 13:55:53 EST 2009

I am writing a macro that defines some exported values. I want one more macro to test if it has exports them

(define-syntax M
  (syntax-rules ()
    ((_ n form)
      (begin 
         (module x scheme form)
         (module y scheme
              (require 'x)
              (write n))))))

(M f (begin (provide f) (define f 1)))

but mzscheme -r throws an error:
compile: unbound identifier in module in: f

Though the expected expansion  is compiled with no errors 

(begin
  (module x scheme (begin (provide f) (define f 1)))
  (module y scheme
    (require 'x)
    (write f)))

Why? 


Posted on the users mailing list.