Evaluation

Evaluation is the process by which Lisp determines the value of an expression; Lisp uses the following recursive algorithm:

  1. If the expression to be evaluated is a constant, such as a number, #t or #f, the value is the expression itself.

  2. If the expression is (QUOTE x), which we abbreviate as 'x, the value is x.

  3. If the expression is a symbol, the value is the binding of the symbol (or an error if the symbol is unbound).

  4. Otherwise, the expression must be a list that represents a function call or special form:
    1. Evaluate each element of the function call, in left-to-right order.

    2. Call the function with the values of the arguments.

    3. The value is the value returned by the function.
    Special forms such as if, quote, define, and set! do not evaluate all their arguments.

Note that evaluation ``calls itself'' recursively to evaluate arguments.

Contents    Page-10    Prev    Next    Page+10    Index