Part 2: Procedures!

In Part II, you will add the ability to create and call user-defined procedures. You will add the following features to the interpreter:

  • Lambda procedures, using the (lambda ...) special form
  • Named lambda procedures, using the (define (...) ...) special form
  • Mu procedures, with dynamic scope

User-Defined Procedures

User-defined lambda procedures are represented as instances of the LambdaProcedure class. A LambdaProcedure instance has three instance attributes:

  • formals is a Scheme list of the formal parameters (symbols) that name the arguments of the procedure.
  • body is a Scheme list of expressions; the body of the procedure.
  • env is the environment in which the procedure was defined.