[plt-scheme] syntax form works in top-level env, but not when imported from module.

From: Hans Oesterholt (hdnews at gawab.com)
Date: Sun Nov 13 18:14:02 EST 2005

Could someone look at what's happening with the code
beneath? I just don't understand what's going on.

Thanks in advance,

Hans


*********************************************************
I declare

(module a mzscheme
    (provide a)

(define (is-op? s f)
  (if (eq? s 'like)
      s
      (f)))

(define-syntax a
  (syntax-rules ()
    ((_ c)
     (is-op? 'c (lambda () (* c c))))))

)

(module b mzscheme
    (require "a.scm")
   
(define Q 22)
(display (a Q))(newline)
(display (a like))(newline)

)

Now, in the toplevel environment:

 > (require "a.scm")
 > (a like)
like
 > (a 2)
4

But:

 > (require "b.scm")
b.scm:16:12: compile: unbound variable in module in: like

Now add "(define like 10)"  to b.scm (just above the expansion of (a like))

 > (require "b.scm")
100
like

*********************************************************


Posted on the users mailing list.