3.20 Quasiquoting: quasiquote, unquote, and unquote-splicing
An unquote or unquote-splicing form is recognized in any of the following escaping positions within datum: in a pair, in a vector, in a box, in a prefab structure field after the name position, and in hash table value position (but not in a hash table key position). Such escaping positions can be nested to an arbitrary depth.
An unquote-splicing form must appear as the car of a quoted pair, as an element of a quoted vector, or as an element of a quoted prefab structure. In the case of a pair, if the cdr of the relevant quoted pair is empty, then expr need not produce a list, and its result is used directly in place of the quoted pair (in the same way that append accepts a non-list final argument).
> (quasiquote (0 1 2))
'(0 1 2)
> (quasiquote (0 (unquote (+ 1 2)) 4))
'(0 3 4)
> (quasiquote (0 (unquote-splicing (list 1 2)) 4))
'(0 1 2 4)
> (quasiquote (0 (unquote-splicing 1) 4))
unquote-splicing: contract violation
> (quasiquote (0 (unquote-splicing 1)))
'(0 . 1)
A quasiquote form within the original datum increments the level of quasiquotation: within the quasiquote form, each unquote or unquote-splicing is preserved, but a further nested unquote or unquote-splicing escapes. Multiple nestings of quasiquote require multiple nestings of unquote or unquote-splicing to escape.
`(,1 2 3)