(backquote arg) arg: any form
Quasi-quotation.
The backquote
macro expands into code which constructs a copy of its argument. This
usually means that it expands into a tree of nested calls to the arr
function.
(backquote (a (b c) 10))
; ...expands to...
(arr 'a (arr 'b 'c) 10)
By default, evaluation is completely suppressed: backquote
considers all of its input to
be literal data instead. However, the unquote
form can be used to copy part
of the input into the output verbatim. This means that when the backquote
form is
evaluated (not when it's expanded!), the unquoted form will be evaluated, and its result
will be interleaved into the output.
(backquote (w x (y z) 3.14))
(backquote (w ~x ~(y z) 3.14))
; ...expands to...
(arr 'w 'x (arr 'y 'z) 3.14)
(arr 'w x (y z) 3.14)
When backquote
encounters symbols which end in #
, such as example#
, it will
replace each distinct symbol with a fresh gensym
, each time the backquote
form is evaluated. (This does not recurse through unquote
forms, or nested
backquote
forms.)
(backquote (a# b# (a# ~b#)))
; ...expands to...
(do
(let gs-a (gensym 'a))
(let gs-b (gensym 'b))
; note that gs-a appears twice
(arr gs-a gs-b (arr gs-a b#)))
(backquote x)
is usually abbreviated
as `x
.