Consider the following macro definition in R7RS scheme:
(define-syntax foo
(syntax-rules ()
((_ bar)
(begin
(define baz 42)
(define-syntax bar
(syntax-rules ()
((_) baz)))))))
I have loaded this file into the repl of chibi-scheme
and entered:
> (foo bar)
> (bar)
Instead of the expected output 42
, I got:
ERROR: undefined variable: baz
Why is this so and how can I pass the defined value of baz
in the outer macro to the inner macro?