[plt-scheme] enclosing-module-name

From: support at taxupdate.com (support at taxupdate.com)
Date: Wed Apr 4 11:12:36 EDT 2007

On Wed, Apr 04, 2007 at 02:31:25PM -0400, Matthias Felleisen wrote:

> (module test mzscheme
>   (define-syntax (test-module-name stx)
>     (syntax-case stx ()
>       ((_ x)
>        (let ((prop (syntax-property stx 'enclosing-module-name)))
>          #`(#%module-begin (display (quote #,prop)))))))
>   (provide
>    [all-from-except mzscheme #%module-begin]
>    [rename test-module-name #%module-begin]))
> (module imp test
>   1)
> (require imp)

I'm attempting to adapt the above to my application, which requires
something like:

(module test mzscheme
  (define-syntax (foo stx)
    (syntax-case stx ()
      ((_ exp)
       (let ((prop (syntax-property stx 'enclosing-module-name)))
         #`(printf "~a in module ~a" exp (quote #,prop))))))

  (define-syntax (template stx)
    (syntax-case stx ()
      ((_ name exp ...)
       #`(module name mzscheme
            (require test)
            (provide (all-defined))
            exp ...)))))
   (provide (all-defined)))

(require test)
(template a (foo 'a1))
(require a)

This gives me "expand: unbound variable in module in: foo"

What am I missing here?


Posted on the users mailing list.