Previous: , Up: Evaluation   [Contents][Index]

5.7.4 Quoting

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

The general way to prevent evaluation of a form is to simply precede it by a single quote-mark.

Special Form: quote form

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.