[plt-scheme] Macros in Macros

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Sun Oct 12 19:59:25 EDT 2008

On Sun, Oct 12, 2008 at 7:47 PM, Henk Boom <lunarc.lists at gmail.com> wrote:
> The following works:
>
> ---
> #lang scheme/base
>
> (require (for-syntax scheme/base
>                     (for-syntax scheme/base)))
> (provide test)
>
> (define-syntax (test stx)
>  (define-syntax (foo stx)
>    #`#,2)
>  #`#,(foo stx))
> ---
>
> I have two questions. First, is nesting for-syntax clauses the right
> way to be able to write these sorts of macros? Secondly, is there a
> way to define the 'foo' macro globally for the module? I'm prohibited
> from including it in a begin-for-syntax clause.

If you split your program up into separate modules, you can define the
foo macro in one, and require it for syntax in the other, and you will
then have a transformer-time macro available in the entirety of the
second module.

-- 
Carl Eastlund


Posted on the users mailing list.