[plt-scheme] Re: bug?
> From: David Feuer <dfeuer at techhouse.org>
>
> These _could_ be right, but I very much doubt it.
>
> ``(3 4 ,,@'(3 4 5)) ==DrSchemev200alpha19=>
> `(3 4 (unquote 3 4 5))
>
> ``(3 4 ,@,'(3 4 5))
> ==> `(3 4 ,@(3 4 5))
Those are both correct, according to r5rs. If you reevaluate `(3 4
(unquote 3 4 5)), you get an error, which is a bug in the r5rs spec.
Doubly evaluating ``(3 4 ,,@'(3 4 5)) should yield (3 4 3 4 5) to be
compatible with common lisp backquote, which is what r5rs was trying
to do. To fix this, you should either extend quasiquote to have ``(3
4 ,,@'(3 4 5)) evaluate to `(3 4 ,3 ,4 ,5) or make `(3 4 (unquote 3 4
5)) evaluate to (3 4 3 4 5). The latter approach is uglier, but a
little more backwards-compatible (in case someone was actually
counting on the exact result of the first evaluation even though it
was not a valid expression for a second evaluation), and it is the
approach taken by chez scheme. (You can also do both extensions.)
As for "Why the hell should nested quasiquote work this way?", you
need to study traditional (double-eval) macros that expand into
definitions of other traditional macros before you will see that these
semantics are convenient.
... which makes the exercise of implementing nested quasiquote using
syntax-rules a rather ironic endeavor.
-al