[R6RS] Bawden quasiquote extension

Michael Sperber sperber at informatik.uni-tuebingen.de
Thu Jun 22 13:33:45 EDT 2006

dyb at cs.indiana.edu writes:

> Would someone please explain in what way the Bawden quasiquote extension
> is incompatible with R5RS?  It's been a while since I looked at it, but I
> thought it was upwardly compatible when I implemented it.

In a nutshell, nested backquotes in R5RS generate S-expressions that
contain quasiquote expressions.  They generate the wrong quasiquote
expressions in the case of the mapping construct.  Consider the
example from Cltl2:

(define q '((union x y) (list 'sqrt 9)))

I believe R5RS pretty much mandates this expansion:

``(foo ,, at q)
=> (quasiquote (foo (unquote (union x y) (list 'sqrt 9))))

But you can see that it's wrong (at least per the Common Lisp
definition, and it's a syntax error) as the unquote would need to be
distributed over the elements of q.

Alan's paper isn't really clear on the point, but the expander that's
in his appendex, as well as the Common Lisp expander, always generate
code that doesn't contain quasiquote at all---instead, it generates
'real code' and thus creates concrete references to various standard

(qq-expand '`(foo ,, at q))
(append '(append) (append (list (append '(quote) (append (list (append '(foo) '())) '()))) (append (list (append '(append) (append (list (append '(list) (append q '()))) (append (list (append '(quote) (append '(()) '()))) '())))) '())))

Guy Steele's expander optimizes this significantly, which is why
Common Lisps typically generate something like this:

``(foo ,, at q) => (LIST 'FOO (UNION X Y) (LIST 'SQRT 9))

I don't know if we want to do this.  Supposedly, we might do:

``(foo ,, at q)
=> (quasiquote (foo (unquote (union x y)) (unquote (list 'sqrt 9))))

But that's different from what Bawden's paper suggests, and I haven't
really thought it through yet.

Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla

More information about the R6RS mailing list