[   ^ to index...   |   <-- previous   |   next -->   ]

Function applications

When a closure is applied, an activation (also "activation record") is created, containing

  1. A copy of the closure's parent pointer
  2. Bindings of actual parameters to formal parameters

The procedure executes with the activation as the current environment. If the function contains let-expressions, they produce local bindings on evaluation, just like any other let-expression.

(* Declare f *)
fun f(x, y) =
  let
    fun nested(z)
        = a + x + z    
  in
    nested(y)
  end;

(* Apply f *)       
f(2,10);
            
[function application, step 1: create activation]

Notice that the nested closure's environment pointer points to the scope of the let in which it was created. When nested is applied, its activation is created just like any other function's:

(* Declare f *)
fun f(x, y) =
  let
    fun nested(z)
        = a + x + z    
  in
    nested(y)
end;

(* Apply f *)       
f(2,10);
            
[function application, step 2: create nested activation]

Keunwoo Lee
Last modified: Wed May 2 21:16:22 PDT 2001