[plt-scheme] #%top usage

From: support at taxupdate.com (support at taxupdate.com)
Date: Thu Apr 12 18:05:31 EDT 2007

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)

The first x (at top level environment) produces the "not defined: x" message.

(module test newlang
  (require-for-syntax newlang)   

(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?


Posted on the users mailing list.