Structured Programming with go to Statements
DONALD E. KNUTH
Stanford University, Stanford, California 9~S05
A consideration of several different examples sheds new light on the problem of ereat-
ing reliable, well-structured programs that behave efficiently. This study focuses
largely on two issues: (a) improved syntax for iterations and error exits, making it
possible to write a larger class of programs clearly and efficiently without
ments; (b) a methodology of program design, beginning with readable and correct,
but possibly inefficient programs that are systematically transformed if necessary into
efficient and correct, but possibly less readable code. The discussion brings out op-
posing points of view about whether or not
statements should be abolished;
some merit is found on both sides of this question. Fina!ly, an attempt is made to
define the true nature of structured programming, and to recommend fruitful direc-
tions for further study.
Keywords and phrases:
statements, language design,
event indicators, recursion, Boolean variables, iteration, optimization of programs,
program transformations, program manipulation systems searching, Quieksort,
4.0, 4.10, 4.20, 5.20, 5.5, 6.1 (5.23, 5.24, 5.25, 5.27)
You may go when you will go,
And I will stay behind.
--Edna St. Vincent Millay
Most likely you go your way and I'll go mine.
--Song title by Bob Dylan
Do you suffer from painful elimination?
--Advertisement, J. B. Williams Co.
A revolution is taking place in the way we
write programs and teach programming, be-
cause we are beginning to understand the
associated mental processes more deeply. It
is impossible to read the recent book
[17; 55] without having it
This research was supported in part by the Na-
tional Science Foundation under grant number
GJ 36473X, and by IBM Corporation.
change your life. The reasons for this revolu-
tion and its future prospects have been aptly
described by E. W. Dijkstra in his 1972 Tur-
ing Award Lecture, "The Humble Program-
As we experience this revolution, each of
us naturally is developing strong feelings one
way or the other, as we agree or disagree
with the revolutionary leaders. I must admit
to being a nomhumble programmer, egotisti-
Copyright (~) 1974, Association for Computing Machinery, Inc. General permission to republish,
not for profit, all or part of this material is granted, provided that ACM's copyright notice is
given and that reference is made to this publication, to its date of issue, and to the fact that reprint-
ing privileges were granted by permission of the Association for Computing Machinery.
Computing Surveys, V?L 6, No. 4, Dee, ember 1974