EWD249 - 25
|
v
+- - - - - - - - - - -+
| +---------+ |
| +->| ? | |
| ^ +---------+ |
| | | | |
| | +-----+ | |
| | | S | | |
| | +-----+ | |
| | | | |
| +-----+ | |
+- - - - - - - - | - - +
v
while ? do S
|
v
+- - - - - - - - - - -+
| +---------+ |
| +->| S | |
| ^ +---------+ |
| | | |
| | +---------+ |
| | | ? | |
| | +---------+ |
| | | | |
| +-----+ | |
| | |
+- - - - - - - - | - - +
v
repeat S until ?
These flowcharts also share the property of a single entry at the top and a single exit at the bottom. They enable us to express that the action represented by the dotted block is on closer inspection a time-succession of "a sufficient number" of subactions of a certain type.
We have now seen three types of decomposition; we could call them "concatenation", "selection" and "repetition" respectively. The first two are understood by enumerative reasoning, the last one by mathematical induction.
The programs that can be written using the selection clauses and the repetition clauses as only means for sequencing control, permit straightforward translation into a programming language that is identical but for the fact that sequencing control has to be expressed by jumps to labelled points. The converse is not true. Alternatively: restricting ourselves to the three mentioned types of decomposition leads to flowcharts of a restricted topology compared with the flowcharts one can make when arrows can be drawn from any block leading into any other. Compared with that greater freedom, to restrict oneself to the clauses presents itself as a sequencing discipline.
Why do I propose to adhere to this sequencing discipline? The justification for this decision can be presented in many ways and let me try a number of them in the hope that at least one of them will appeal to my readers.
Eventually, one of our aims is to make such well-structured programs that the