Hi,
thanks for asking this question.
Am 08.03.2017 um 10:06 schrieb Takashi Kato:
> Hi,
>
> I believe the test case "Auxiliary definitions in custom macro
> transformers" is incorrect. The
> definition of the test is the following:
>
> (define-syntax my-macro-transformer
> (syntax-rules ()
> ((my-macro-transformer)
> (begin (define foo 2)
> (syntax-rules ()
> ((_) foo))))))
> (letrec-syntax ((foo (my-macro-transformer)))
> (foo))
>
> However this would be expanded to like this:
>
> (letrec-syntax ((foo (begin (define foo 2)
> (syntax-rules ()
> ((_) foo)))))
> (foo))
The spec allows that "in order to facilitate writing sophisticated
custom macro transformers" transformer specs expand into sequences of
multiple definitions eventually followed by a transformer spec (which is
the case in the example above). The scope of these definitions are in
the scope of the bindings of the letrec-syntax binding construct.
The "foo" inside "(define foo 2)" and the foo in the syntax-rules
template are effectively being renamed due to hygiene. Thus, the whole
construct expands into "2".
Was my explanation helpful?
Best,
Marc