[plt-scheme] #%top usage

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Apr 13 18:57:58 EDT 2007

At Thu, 12 Apr 2007 22:05:31 +0000, support at taxupdate.com wrote:
> 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?

The problem is that `#%module-begin' from `mzscheme' inserts

   (require-for-syntax mzscheme)

into a module using the `mzscheme' language. Since `newlang' re-exports
MzScheme's `#%module-begin', bodies of modules using `newlang' also get
the above line.

To get rid of it, change `newlang' to

(module newlang mzscheme
  (provide (all-from-except mzscheme #%top #%module-begin))
  (provide (rename top #%top)
           (rename #%plain-module-begin #%module-begin))
  ...)


Matthew




Posted on the users mailing list.