From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,9a0ff0bffdf63657 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public From: rgardner@nyx.net (Ray Gardner) Subject: Re: Software landmines (loops) Date: 1998/09/07 Message-ID: <905187520.32147@iris.nyx.net> X-Deja-AN: 388743287 X-Disclaimer: Nyx is a Free Public Access Internet Service: http://www.nyx.net Nyx is not responsible for the actions of its users. Our AUP / Free Speech Policy are at http://www.nyx.net/policies/ Direct complaints to abuse@nyx.net References: <6rf59b$2ud$1@nnrp1.dejanews.com> <6rfra4$rul$1@nnrp1.dejanews.com> <35DBDD24.D003404D@calfp.co.uk> <6sbuod$fra$1@hirame.wwa.com> <35f51e53.48044143@ <904556531.666222@miso.it.uq.edu.au> <6sgror$je8$3@news.indigo.ie> <6sh3qn$9p2$1@hirame.wwa.com> <35ece7ee.1489912@news.erols.com> <905134925.147581@iris.nyx.net> <35f34bbd.7903825@news.erols.com> X-Post-Path: iris.nyx.net!rgardner@nyx10.nyx.net Organization: random access Reply-To: rgardner@acm.org NNTP-Posting-Date: Mon, 07 Sep 1998 10:58:40 MDT Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Originator: rgardner@nyx10.nyx.net (Raymond Gardner) Date: 1998-09-07T00:00:00+00:00 List-Id: ell@access.digex.net (Ell) wrote: > rgardner@nyx.net (Ray Gardner) wrote: > > >.... Of course my main point was > >that the founder(s) of SP did limit the control structures to > >single-entry / single-exit structures, and that still stands. > > And your proof is what? > > Elliott Ell, the "proof" is in my post of 5 Sept 1998, more-or-less directed to you personally, which was the result of more than a couple of hours of research for *your* benefit. Not that I expected any thanks. But since you seem to have missed it, I'll waste a little bandwidth and repost. (I could just give you a pointer to DejaNews, but you seem to never look up any cites people give you. Consider that you asked for a quote from a founder, RCM gives you a direct quote from *the* primary source, and you complain that it's out of print and "RCM knows it". Did you expect a primary source from 25 years ago to be in print? As another poster mentioned, that's what libraries are for. I don't know if you live near any major metropolitan areas, but a quick check shows two copies on the shelf in Denver and one in Boulder in libraries where they can be browsed by anyone.) So once more: [Repost of my message <905028596.876380@iris.nyx.net>] Ell wrote: > >>For example, there's a pernicious myth that exiting (or returning) from > >>the middle of a loop is bad, and that the only proper way to write a > >>loop is to state the termination condition explicitly, as a predicate > >>appearing at the top of the loop. > > >Yes. That pernicious myth is called "structured programming". > > Please cite even just a single structured programming text, or founder > where what you say here was asserted. And later Ell wrote: > The assertion that "single entry, single exit" is a required, or even > desirable, maxim of structured programming is a myth. > > No one (including RCM) can show that this maxim is in fact a coding > heuristic put forward by any of the founders of the structured > paradigm. [Check past posts in this thread.] RCM had responded with a direct quote from Dijkstra, but Ell rejected it without understanding it. And rejected it again after RCM explained it. To recap, in Dijkstra's Notes on Structured Programming in the classic _Structured Programming_ (1972), EWD referred to the single-entry/single-exit property of the flowcharts of the if- then-else, case-of, while-do, and repeat-until control structures. Ell apparently thought EWD was talking about how flowcharts should be represented on a page. EWD was actually using the flowcharts as a graphical aid to make a point about program topology. To support this interpretation, I'll just quote this from the same source, p. 20: "... restricting ourselves to the three mentioned types of decomposition lead 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." EWD then goes on at length to explain why such a topology is desireable. Ell, you might consider this: in the entire monograph EWD never mentions goto, exit, break, return or any other change in the flow of control outside of the selection and repetition statements mentioned above. And he certainly had no such other modes of flow control in mind when he wrote his "GOTO considered harmful" letter; he was accustomed to Algol, which has no exit/break/return or similar statements. (Also consider that goto-less programming in Pascal has the same restriction, since Pascal lacks exit/break/return etc.) Ell, remember that you asked for a cite from "even a single structured programming text, or founder" to support single- entry/single-exit. Okay. Hard to say who you can consider "a" founder other than "the" founder, EWD. But consider Niklaus Wirth: "For the intellectual manageability, it is crucial that the constituent operations at each level of abstraction are connected according to sufficiently simple, well understood _program schemas_, and that each operation is described as a piece of program with _one starting point_ and a _single terminating point_." [Emphases were italics in the original.] "On the Composition of Well-Structured Programs", N. Wirth, in ACM Computing Surveys, December 1974 (Special Issue on Programming), p.249. How about this: "A _proper program_ is a program with a control structure that (1.) has a single entry line and a single exit line, and (2.) for each node, has a path through that node from the entry line to the exit line." _Structured Programming: Theory and Practice, R.C. Linger, H.D. Mills, B.I. Witt, Addison- Wesley, 1979, p. 94. (Ell has already commented on a similar use of the word "proper". Ell, you should understand that the word is being used here in a technical fashion as part of a *definition*, similar to the use of "well-formed formula" in mathematical logic. And, anticipating that you'll claim that this has nothing to do with structured programming per se, I'll point out that the entire book is about programming via the use of "proper programs" as defined above.) Since you mentioned structured COBOL, I'll mention this: "GO TO statements are not allowed. The rationale here is to force programmers to think ahead and use _only_ 1-in, 1-out control structures." ... "STOP RUN may only occur as the last statement of the main procedure of a program. EXIT PROGRAM may only occur as the last paragraph of the main procedure of a subprogram. The rationale here is to make the logical exit of a program identical to the lexical end of its main procedure." _COBOL With Style (Programming Proverbs)_, L.J. Chmura, H.F. Ledgard, Hayden, 1976. A book on structured programming in COBOL. Many other writers have discussed structured programming in terms of single-entry/single-exit control structures, often without using those terms explicitly. But what else could they mean when they develop a programming style that uses only sequence, if-then-else, while-do, repeat-until, and sometimes case-of, without ever mentioning or using goto, return, break, exit, continue, or any other discontinuity of control? For an even heavier dose of Dijkstra, try his _A Discipline of Programming_ (Prentice-Hall, 1976) where he develops a fairly complete theory of proof-oriented _nondeterministic_ procedural programming semantics using only assignment and "guarded commands" for conditional and repetitive (if ... fi and do ... od) statements. He never explicitly mentions "single- entry/single-exit", but it's clear from his exposition that there is no other form of flow control in his system. You mentioned (twice) page 72 of Knuth's _Literate Programming_ (not _The Art of ... as you've twice mis-cited it, and the publisher is CSLI, not CLSC or CLCS as you've twice misnamed them). This page is part of a reprint of Knuth's classic paper "Structured Programming with go to Statements", originally in ACM Computing Surveys, December 1974. You might consider what Knuth said on p. 18 of your book: "It is impossible to read the recent book _Structured Programming_ [Dahl (not Dahle), Dijkstra, and Hoare] without having it change your life." And then take RCM's advice and read the book. Perhaps that's what it'll take to get you to believe that Dijkstra was advocating exactly what RCM said he was. (You won't do it because you might find RCM is right.) BTW, while it's true that Dijkstra considered abstraction to be central to his notion of structured programming, page 72 of Knuth's book nowhere says "It was Dijkstra who thinks of *abstraction* when someone mentions 'structured programming'." It does quote Dijkstra as saying that when he's dealing with one level of abstraction, it occupies 90% of his attention while the rest is kept in mind in the background. Yes, abstraction is key to Dijkstra's notion of structured programming. But so is the use of the limited set of control structures mentioned above, and so is his oft-mentioned "separation of concerns". I've been doing this long enough (30 years) to remember when this stuff was new, and I have many of the original books and papers in my library. I also had the personal experience of bringing structured programming into a COBOL spaghetti shop in 1974. So I do know a little about this stuff. I'm not saying structured programming is only about control structures. And I'm not saying that no one has tried "enhancing" the original idea of structured programming with additional control structures. Wulf, Zahn, Dahl, Knuth and others have suggested other forms of loops. But the original idea, as expounded by Dijkstra, Mills, Wirth, Ledgard, and others does indeed restrict you to single- entry/single-exit control structures, and they don't exit loops in the middle.