Structured Programming with go to StatementsDONALD 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 focuseslargely on two issues: (a) improved syntax for iterations and error exits, making itpossible to write a larger class of programs clearly and efficiently without
state-ments; (b) a methodology of program design, beginning with readable and correct,but possibly inefficient programs that are systematically transformed if necessary intoefficient 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 todefine 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,efficiency
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 wewrite programs and teach programming, be-cause we are beginning to understand theassociated mental processes more deeply. Itis impossible to read the recent book
[17; 55] without having itThis research was supported in part by the Na-tional Science Foundation under grant numberGJ 36473X, and by IBM Corporation.change your life. The reasons for this revolu-tion and its future prospects have been aptlydescribed by E. W. Dijkstra in his 1972 Tur-ing Award Lecture, "The Humble Program-mer" [27l.As we experience this revolution, each ofus naturally is developing strong feelings oneway or the other, as we agree or disagreewith the revolutionary leaders. I must admitto 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 isgiven 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