Path: utzoo!attcan!uunet!mailrus!cs.utexas.edu!usc!rutgers!bpa!sjuphil!ryan From: ryan@sjuphil.uucp (Patrick M. Ryan) Newsgroups: comp.lang.misc Subject: Re: do...while vs. repeat...until (was: Errors aren't that simple) Message-ID: <1990Mar16.135706.28432@sjuphil.uucp> Date: 16 Mar 90 13:57:06 GMT References: <8192@hubcap.clemson.edu> <17000003@hpcvra.CV.HP.COM> <5819.25f7a840@vax1.tcd.ie> <16188@haddock.ima.isc.com> Reply-To: ryan@sjuphil.UUCP (Patrick M. Ryan) Organization: SJU Grad CSC Lines: 30 In article <16188@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes: >In article <5819.25f7a840@vax1.tcd.ie> cbuckley@vax1.tcd.ie writes: >>In article , emuleomo@paul.rutgers.edu (Emuleomo) writes: >>> The other less serious flaw in C is the do...while contruct. >>> I kind of prefer PASCAL's repeat....until construct myself. >> >That's enough to make it a (minor) flaw. Judging from my own personal >experience, it is more natural for a test-at-top loop to specify the condition >for continuing (while), but for a test-at-bottom loop to specify the condition >for terminating (until). I don't know if there's been a study on this; in >fact, I'm not entirely sure how to formalize the concept. a simple hack to fix this problem: #define repeat do #define until(c) while (!(c)) thus, repeat { do { statement; becomes statement; until(condition); while (!(condition)) easy, no? -- patrick m. ryan saint joseph's ryan@sju.edu / ryan%sjuphil.sju.edu@bpa.bell-atl.com university {bpa|burdvax|princeton|rutgers}!sjuphil!ryan philadelphia pmr@gemini.gsfc.nasa.gov pennsylvania