14 Quasiquoting
[Explain why...]
14.1 Escapes: quasiquote, unquote, and unquote-splicing
The quasiquote form is similar to quote:
(quasiquote datum)
However, for each (unquote expr) that appears within the datum, the expr is evaluated to produce a value that takes the place of the unsyntax sub-form.
Examples: |
(1 2 3 4) |
The unquote-splicing form is similar to unquote, but its expr must produce a list, and the unquote-splicing form must appear in a context that produces either a list of vector. As the name suggests, the resulting list spliced into the context of its use.
Examples: |
> (quasiquote (1 2 (unquote-splicing (list (+ 1 2) (- 5 1))) 5)) |
(1 2 3 4 5) |
If a quasiquote form appears within an enclosing quasiquote form, then the inner quasiquote effectively cancels one layer of unquote and unquote-splicing forms, so that a second unquote or unquote-splicing is needed.
14.2 Abbreviating with , , and