[plt-scheme] defines and modules inside macro
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?