[plt-scheme] #%top usage
I'm experimenting with the #%top transformer with the following:
(module newlang mzscheme
(provide (all-from-except mzscheme #%top))
(provide (rename top #%top))
(define-syntax (top stx)
(syntax-case stx ()
((_ . identifier)
(let ((s (syntax-object->datum #'identifier)))
(if (symbol? s)
(syntax/loc stx
(if (not (namespace-variable-value 'identifier #f (lambda () #f)))
(printf "not defined: ~a\n" 'identifier)
(#%top . identifier)))
(syntax/loc stx (#%top . identifier))))))))
(require newlang)
x
The first x (at top level environment) produces the "not defined: x" message.
However:
(module test newlang
(require-for-syntax newlang)
x
)
(require test)
Within the test module, I get "module: identifier already imported (from a
different source) in: #%top" at the require-for-syntax line. In the
test module, where is #%top getting its initial value, and is there a way to
control this?
Wayne