Page:AIM-353.djvu/7

From Wikisource
Jump to: navigation, search
This page has been validated.
Steele and Sussman March 10, 1976 5 LAMBDA: The Ultimate Imperative

Imperative Programming

Lambda calculus (and related languages, such as "pure LISP") is often used for modelling the applicative constructs of programming languages. However, they are generally thought of as inappropriate for modelling imperative constructs. In this section we show how imperative constructs may be modelled by applicative SCHEME constructs.

Compound Statements

The simplest kind of imperative construct is the statement sequencer, for example the compound statement in ALGOL:

begin
       S1:
       S2;
end

This construct has two interesting properties:

  1. It performs statement S1 before S2, and so may be used for sequencing.
  2. S1 is useful only for its side effects. (In ALGOL, S2 must also be a statement, and so is also useful only for side effects, but other languages have compound expressions containing a statement followed by an expression.)

The ALGOL compound statement may actually contain any number of statements, but such statements can be expressed as a series of nested two-statement compounds. That is:

begin
       S1;
       S2;
       ...
       Sn-1;
       Sn;
end

is equivalent to: