Modula-3: Statements

# Statements

> Look into any carpenter's tool-bag and see how many different hammers, chisels, planes and screw-drivers he keeps there---not for ostentation or luxury, but for different sorts of jobs. ---Robert Graves and Alan Hodge

Executing a statement produces a computation that can halt (normal outcome), raise an exception, cause a checked runtime error, or loop forever. If the outcome is an exception, it can optionally be paired with an argument.

We define the semantics of `EXIT` and `RETURN` with exceptions called the exit-exception and the return-exception. The exit-exception takes no argument; the return-exception takes an argument of arbitrary type. Programs cannot name these exceptions explicitly.

Implementations should speed up normal outcomes at the expense of exceptions (except for the return-exception and exit-exception). Expending a thousand instructions per exception raised to save one instruction per procedure call would be reasonable.

If an expression is evaluated as part of the execution of a statement, and the evaluation raises an exception, then the exception becomes the outcome of the statement.

The empty statement is a no-op. In this report, empty statements are written `(*skip*)`.

Each of the statments is described below

- Assignment
- Procedure call
- Eval
- Block statement
- Sequential composition
- Raise
- Try Except
- Try Finally
- Loop
- Exit
- Return
- If
- While
- Repeat
- With
- For
- Case
- Typecase
- Lock
- Inc and Dec

    Last modified on Wed Apr  3 09:38:55 PST 1996 by heydon
         modified on Fri Apr 15 08:41:20 PDT 1994 by kalsow