[plt-scheme] Accessing scheme primitives within macros redefining them

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Nov 25 12:48:43 EST 2003

At Tue, 25 Nov 2003 12:08:34 -0500, Jim Witte wrote:
>    In Chez, there's an (import scheme) command, so I could right (I 
> think)
> (define-syntax quasiquote
>    (syntax-rules ()
>      (_ . rest)
>      (begin
>         (do-quasi-check rest)
>         (import scheme)
>         (quasiquote rest))))

I don't think this would work in Chez. When a macro expansion
introduces an `import', the `import' doesn't bind other things
introduced by the same macro expansion. Roughly, the `import' instead
binds in the context of the macro use. (The macros in the POPL paper
rely on this behavior.)

In PLT Scheme, I think you can do what you want only through modules:

 (module my-qqm mzscheme
  (define-syntax my-qq
   (syntax-rules ()
     [(_ rest)
         (do-quasi-check rest)
         (quasiquote rest))]))
   (provide (rename my-qq quasiquote)))

 (require my-qqm)


Posted on the users mailing list.