[plt-scheme] Problem with defmacro and modules

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Mar 1 17:20:44 EST 2007

On Mar  1, Andreas Rottmann wrote:
> Hi!
> 
> I stumbled across strange behaviour using mzscheme 360; the
> following code will fail with "reference to undefined identifier:
> module":
> [...]

Here's a smaller version of your bug:

  (module baz (lib "r5rs.ss" "r5rs"))
  (require baz)
  (module qux mzscheme)

or even shorter:

  (require (lib "r5rs.ss" "r5rs"))
  (module qux mzscheme)

The thing is that "r5rs/r5rs.ss" is not a well behaved module -- if
you look in the source, you'll see that it changes a few global
parameters to provide an r5rs environment.  The most obvious problem
is that it's doing this:

  (current-namespace (scheme-report-environment 5))

which is changing the following interactions.  The reason it's there
is to be able to run

  mzscheme -M r5rs

and get an R5RS-version of mzscheme.  If you want to use R5RS in a
module, use (lib "lang.ss" "r5rs") instead.

This is all described in the doc.txt file, and I added a warning now
for not using r5rs.ss like you did.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.