Quasiquote

quasiquote

macro

Macro

                        (quasiquote form)
                    

is a quotation that may have expressions inside it in the form of unquote and unquote-splicing.

Example:

(defdynamic x 1)
(defdynamic y '(2 3 4))

(quasiquote (1 (unquote x) (unquote-splicing y))) ; => (1 1 2 3 4)
; using the reader macros
`(1 %x %@y)) ; => (1 1 2 3 4)

unquote

macro

Macro

                        (unquote form)
                    

unquotes (i.e. evaluates) an expression form inside a quasiquote. It will generate an error message when used outside a quasiquote form.

Example:

(defdynamic x 2)

(quasiquote (+ (unquote x) 1)) ; => (+ 2 1)

unquote-splicing

macro

Macro

                        (unquote-splicing form)
                    

unquotes (i.e. evaluates) an expression form inside a quasiquote and splices it in, i.e. flattens the expression. It will generate an error message when used outside a quasiquote form.

Example:

(defdynamic x '(1 2)

(quasiquote (+ (unquote-splicing x))) ; => (+ 1 2)