a) The current dictionary is replaced by its extension. The extension contains the
name of the function being defined, together with a temporary Void
-value.
b) Then a new function is created as a 4-tuple: the name of the function, the formal arguments, the body expression and the current dictionary (= the dictionary of function-definition). The dictionary is needed because Pico implements lexical scoping. Hence, the 'current dictionary' (i.e. dictionary of definition) will be needed when evaluating the body of the function (which happens when calling it)
c) Now the Void
value in the dictionary is replaced by the function
which was just created.
Why: The trick with Void
is needed because we are defining a
recursive structure: the function needs the environment of definition. But
this environment of definition must contain the function itself because we might
want to call the function recursively. If you understand this, try to think back
and understand the difference between let
and letrec
in Scheme.