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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: Matthew Heaney Subject: Re: Software landmines (loops) Date: 1998/10/09 Message-ID: #1/1 X-Deja-AN: 399259518 Sender: matt@mheaney.ni.net References: <6r9f8h$jtm$1@nnrp1.dejanews.com> <6renh8$ga7$1@nnrp1.dejanews.com> <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> NNTP-Posting-Date: Thu, 08 Oct 1998 22:43:41 PDT Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-10-09T00:00:00+00:00 List-Id: rgardner@nyx.net (Ray Gardner) writes: > Matthew Heaney wrote: > > rgardner@nyx.net (Ray Gardner) writes: > > > > > RCM had responded with a direct quote from Dijkstra, but Ell 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. > > > > Oh! You were doing well up to that last line. Read about the > > dowhiledo structure, in section 3.3.3, Iteration Structures, of > > Structured Programming, by Linger, Mills, and Witt. > > > Thanks for the correction, Matt. 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. > The middle-exit loop (with single exit) is still such a structure > whether Dijkstra used it or not. (He didn't). I still say we're splitting hairs, here. As Mills points out, the sequence of actions is: read N test N process N read N test N process N read N test N There are two ways to turn this into a loop. The most natural way (according to me, and Soloway et al) is like this: loop read N exit when N = 0 process N end loop This describes the enumerated list of actions above. The "classic" way is like this: read N while N /= 0 loop process N read N end loop I recently read Dijkstra's structured programming monograph. He explicates his philosophy in the section 7 (p. 16), titled "On Understanding Programs." His argument is that the static program text should be close to what happens dynamically, or, more simply, that programs be understandable. I argue that the middle-exit construction shown above satisfies Dijkstra's "restricted topology" in the sense that a reader of the (static) program text can easily understand what happens at run-time. His philosophy is "to make a program in such a way that its correctness [can] be proved without undue intellectual labor." [p. 39] Even though Dijkstra doesn't specifically mention the middle-exit construction in his monograph, I would argue that that construction satisfies his ultimate goal, which easy-to-understand, provably-correct programs.