Execution of Functions

When Lisp encounters a function call, it does the following:

  1. Each argument specified in the call to the function is evaluated to produce a single value, the actual argument.

  2. A new stack frame or environment is created to hold bindings for the execution of the function.

  3. Each formal argument (symbol specified as an argument in the definition of the function) is bound to the corresponding actual argument, and this binding is added to the current stack frame.

  4. The code of the function is executed; this produces a value, which is returned as the value of the function.

  5. The stack frame is removed (``popped off''). The variables that were bound inside the function revert to their previous values (or become unbound) when the function exits.

Contents    Page-10    Prev    Next    Page+10    Index