[plt-scheme] #%top usage

From: support at taxupdate.com (support at taxupdate.com)
Date: Sat Apr 14 05:40:18 EDT 2007

On Sat, Apr 14, 2007 at 06:57:58AM +0800, Matthew Flatt wrote:
> At Thu, 12 Apr 2007 22:05:31 +0000, support at taxupdate.com wrote:
> (module newlang mzscheme
>   (provide (all-from-except mzscheme #%top #%module-begin))
>   (provide (rename top #%top)
>            (rename #%plain-module-begin #%module-begin))
>   ...)

This fixes the "definition already imported" error, thanks.  Here's the
code:

(module newlang mzscheme
  (provide (all-from-except mzscheme #%top #%module-begin))
  (provide (rename top #%top)
           (rename #%plain-module-begin #%module-begin))
  (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))))))))

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

(require test)

This gets a message "expand: unbound variable in module in: x".  Why isn't the
new #%top kicking in within the test module?

Wayne


Posted on the users mailing list.