Next: Data, Previous: Form, Up: Welcome to Lisp [Contents][Index]
In this section we take a closer look at how expressions are evaluated.
When Lisp evaluates a function call, it does so in two steps:
If any of the arguments are themselves function calls, they are evaluated according to the same rules.
Not all the operators in Common Lisp are functions, but most are. And function calls are always evaluated this way. The arguments are evaluated left-to-right, and their values are passed to the function, which returns the value of the expression as a whole. This is called the evaluation rule for Common Lisp.
One operator that does not follow the Common Lisp evaluation rule is quote
.
The quote
operator is a special operator, meaning that it has a distinct
evaluation rule of its own. And the rule is: do nothing. The quote
operator
takes a single argument and just returns it verbatim.
> (quote (+ 3 5) (+ 3 5)
Common Lisp defines ‘'’ as an abbreviation for quote
. You can get the effect
of calling quote
by affixing a ‘'’ to the front of any expression:
> '(+ 3 5) (+ 3 5)
Lisp provides the quote
as a way of protecting expressions from evaluation.