I've just verified that the implementations of unquote and unquote-splicing
in Guile do not conform to R6RS. Perhaps this is intentional, but it would
be a shame because the change in R6RS is certainly one for the better.
Scheme's quasiquotation is defined very well (it's even used as a reference
in Common Lisp's backquote definition) but ... it did have a major drawback.
unquote (and unquote-splicing as well) cannot be applied to multiple
expressions. This messes things up a little, especially when you're dealing
with nested quasiquotations. Anyway, you can't do things like this (like you
can in CL and R6RS):
(let ((name 'foo))
`((unquote name name name)))
=> (foo foo foo)
But the latter example is nothing. You can get around it in a second. There
are however MUCH worse-case scenarios which, quite possibly, cannot be
worked around (or at most with ugly solutions).
The current rules for evaluation are (from R6RS):
If an (unquote <expression> ...) form appears inside a <qq template>,
however, the <expression>s are evaluated (“unquoted”) and their results are
inserted into the structure instead of the unquote form.
If an (unquote-splicing <expression> ...) form appears inside a <qq
template>, then the <expression>s must evaluate to lists; the opening and
closing parentheses of the lists are then “stripped away” and the elements
of the lists are inserted in place of the unquote-splicing form.
Any unquote-splicing or multi-operand unquote form must appear only within a
list or vector <qq template>.
That just about says it all. Alan Bawden discussed the previous flaw in
Scheme. Now it's cured. Hope to see the new rules in Guile too.
"Sono nato senza conoscere nulla e ho avuto un po' di tempo per cambiare qua
e là questa mia condizione." (Richard P. Feynman)