[R6RS] Internal DEFINE vs. macros
dyb at cs.indiana.edu
dyb
Fri Apr 15 09:09:35 EDT 2005
(let-syntax ((foo (syntax-rules ()
((foo ?x) (define ?x 'outer)))))
(let ()
(define-syntax foo
(syntax-rules ()
((foo) (define ?x 'inner))))
(foo a)
a))
> produces outer on PLT, but on Chez says:
>
> Error: invalid syntax (foo a).
>
> Why? (If you think I should wait until the full description of
> SYNTAX-CASE is out let me know.)
Chez Scheme processes body forms from left to right and adds macro
definitions to the compile-time environment as it proceeds. It looks like
PLT Scheme doesn't add the macro definitions until after it has determined
the set of definitions. In both systems, define rhs expressions are
expanded, along with the body expressions that follow the definitions,
only after the set of definitions is determined. I would guess that,
in PLT Scheme, the first non-definition is partially expanded as the
set of definitions is uncovered and must be completely reexpanded after,
which isn't necessary in Chez Scheme. In any case, I'm sure we can iron
out the differences.
Kent
More information about the R6RS
mailing list