Next Previous Contents

6. Let Environments

This is section 3.4 in Ullman. Sections 3.5 and 3.6 are case studies, so you do not need to read them.

The let expression allows you to define local values and functions. It is similar to the context in C/C++ and Java defined by curly braces ``{}''. The syntax is:

let
  val variable1 = expression1[;]
  val variable2 = expression2[;]
  fun function1 = expression3[;]
  fun function2 = expression4[;]
in
  expression5
end;

Any number of expressions can be present in the definition section, semicolons are optional. Any type of expression at all can be present in the body of the expression. The value returned by the let expression is the value of the expression in the body.


Next Previous Contents