Common Lisp the Language, 2nd Edition     Next: Functions Up: Forms Previous: Macros

## 5.1.5. Function Calls

If a list is to be evaluated as a form and the first element is not a symbol that names a special form or macro, then the list is assumed to be a function call. The first element of the list is taken to name a function. Any and all remaining elements of the list are forms to be evaluated; one value is obtained from each form, and these values become the arguments to the function. The function is then applied to the arguments. The functional computation normally produces a value, but it may instead call for a non-local exit; see throw. A function that does return may produce no value or several values; see values. If and when the function returns, whatever values it returns become the values of the function-call form.

For example, consider the evaluation of the form (+ 3 (* 4 5)). The symbol + names the addition function, not a special form or macro. Therefore the two forms 3 and (* 4 5) are evaluated to produce arguments. The form 3 evaluates to 3, and the form (* 4 5) is a function call (to the multiplication function). Therefore the forms 4 and 5 are evaluated, producing arguments 4 and 5 for the multiplication. The multiplication function calculates the number 20 and returns it. The values 3 and 20 are then given as arguments to the addition function, which calculates and returns the number 23. Therefore we say (+ 3 (* 4 5)) => 23. X3J13 voted in October 1988 (FUNCTION-CALL-EVALUATION-ORDER)   to clarify that while the arguments in a function call are always evaluated in strict left-to-right order, whether the function to be called is determined before or after argument evaluation is unspecified. Programs are in error that rely on a particular order of evaluation of the first element of a function call relative to the argument forms.      Next: Functions Up: Forms Previous: Macros

[email protected]