Concepts of Programming Languages

(Sean Pound) #1
8.6 Conclusions 379

[] q3 > q4 -> temp := q3; q3 := q4; q4 := temp;
od

Dijkstra’s guarded command control statements are interesting, in part
because they illustrate how the syntax and semantics of statements can have an
impact on program verification and vice versa. Program verification is virtually
impossible when goto statements are used. Verification is greatly simplified if
(1) only logical loops and selections are used or (2) only guarded commands
are used. The axiomatic semantics of guarded commands is conveniently speci-
fied (Gries, 1981). It should be obvious, however, that there is considerably
increased complexity in the implementation of the guarded commands over
their conventional deterministic counterparts.

8.6 Conclusions


We have described and discussed a variety of statement-level control structures.
A brief evaluation now seems to be in order.
First, we have the theoretical result that only sequence, selection, and pre-
test logical loops are absolutely required to express computations (Böhm and
Jacopini, 1966). This result has been used by those who wish to ban uncon-
ditional branching altogether. Of course, there are already sufficient practical
problems with the goto to condemn it without also using a theoretical reason.
One of the main legitimate needs for gotos—premature exits from loops—can
be met with highly restricted branch statements, such as break.
One obvious misuse of the Böhm and Jacopini result is to argue against
the inclusion of any control structures beyond selection and pretest logical
loops. No widely used language has yet taken that step; furthermore, we doubt
that any ever will, because of the negative effect on writability and readability.
Programs written with only selection and pretest logical loops are generally
less natural in structure, more complex, and therefore harder to write and
more difficult to read. For example, the C# multiple selection structure is a
great boost to C# writability, with no obvious negatives. Another example is
the counting loop structure of many languages, especially when the statement
is simple, as in Ada.
It is not so clear that the utility of many of the other control structures
that have been proposed is worth their inclusion in languages (Ledgard and
Marcotty, 1975). This question rests to a large degree on the fundamental ques-
tion of whether the size of languages must be minimized. Both Wirth (1975)
and Hoare (1973) strongly endorse simplicity in language design. In the case of
control structures, simplicity means that only a few control statements should
be in a language, and they should be simple.
The rich variety of statement-level control structures that have been
invented shows the diversity of opinion among language designers. After all
the invention, discussion, and evaluation, there is still no unanimity of opinion
on the precise set of control statements that should be in a language. Most
Free download pdf