Previous: Self-Evaluating Forms, Up: Evaluation [Contents][Index]
As the above sections explain some types of Lisp object have special meaning to the Lisp evaluator (namely the symbol and list types) this means that if you want to refer to a symbol or a list in a program you can’t because the evaluator will treat the form as either a variable reference or a function call respectively.
To get around this Lisp uses an idea called quoting. The special
form quote
simply returns its argument without evaluating it.
For example,
(quote my-symbol) ⇒ my-symbol
the quote
form prevents the my-symbol
being treated as a
variable—it is effectively ‘hidden’ from the evaluator.
Writing ‘quote’ all the time would be a bit time-consuming so
there is a shortcut: the Lisp reader treats any form x preceded
by a single quote character (‘'’) as the form (quote
x)
. So the example above would normally be written as,
'my-symbol ⇒ my-symbol
The general way to prevent evaluation of a form is to simply precede it by a single quote-mark.
This special form returns its single argument without evaluating it. This is used to quote constant objects to prevent them from being evaluated.
For another form of quoting, see Backquoting.