[plt-scheme] Macros in the same module

From: Noel Welsh (noelwelsh at gmail.com)
Date: Thu May 7 08:25:53 EDT 2009

I think you want a define-for-syntax not a define-syntax, or you need
to put 'expand-rules' into a (syntax ...). One macro can definitely
expand into another:

#lang scheme/base

(define-syntax foo
  (syntax-rules ()
    [(foo name val)
     (bar name val)]))

(define-syntax bar
  (syntax-rules ()
    [(bar name val)
     (define name val)]))

(foo a 42)
a

N.

On Thu, May 7, 2009 at 1:00 PM, Paulo J. Matos <pocmatos at gmail.com> wrote:
> Hi all,
>
> I have defined a macro which expands into a define and then uses
> another macro defined in the same module to expand into the define
> body.
> However, the first macro cannot 'see' the second:
>  expand: unbound identifier in module (in the transformer environment,
> which does not include the macro definition that is visible to
> run-time expressions) in: expand-rules
...


Posted on the users mailing list.