next up previous contents
Next: Implementation Up: Syntax and Data Structure Previous: Function Pointers

Functions and Function Definitions

Lisp functions are divided into two main classes. One includes functions defined as lambda expressions, which are interpreted, the other includes compiled functions and functions that are defined in the LISP system, which are accessed via function pointers. Arguments are passed to interpreted functions by lambda convention (saving the current value of the lambda dummy-argument-identifier onto an internal stack (the `alist' stack) and temporarily assigning the current argument to the dummy-argument-identifier, as value), to compiled functions the arguments are passed through the registers (internal defined static memory locations). Functions are further classified by the argument passing mechanism peculiar to them:

spread
functions have a fixed number of arguments (with a maximum of 16) which are bound to lambda parameters on one-to-one basis. Giving incorrect number of arguments to these results in a mismatch error.
nospread
functions may have a variable number of arguments,but have a single formal parameter, which is bound to the list of the actual arguments. (Obvious examples are the LISP functions as and, or, cond, list
eval
type functions receive their arguments pre-evaluated in contrast to
noeval
type functions which receive their arguments unevaluated (as in the case of and, cond, quote)

All of the possible eight combinations are implemented as follows:

tabular430

expr, fexpr, nexpr, and lexpr's are lambda expressions, subr, fsubr, nsubr, and lsubr's are function pointers.

In addition to these there is one more type: `macro'. A function of type macro has a single formal parameter which is bound to the entire expression invoking it, and the value returned by it is reevaluated.





Gokturk UCOLUK
Fri Nov 1 21:52:13 EET 1996