Xref: utzoo comp.lang.c:26954 comp.lang.misc:4476 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c,comp.lang.misc Subject: do...while vs. repeat...until (was: Errors aren't that simple) Message-ID: <16188@haddock.ima.isc.com> Date: 15 Mar 90 23:58:42 GMT References: <8192@hubcap.clemson.edu> <17000003@hpcvra.CV.HP.COM> <5819.25f7a840@vax1.tcd.ie> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Followup-To: comp.lang.misc Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 20 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. > >How can this be a flaw? The two constructs are identical except for the fact >that the condition is reversed... 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. And no, I did *not* learn Pascal before C. At worst, my opinion may be slightly polluted from Ratfor; but I believe there's a sense in which repeat...until is really better. Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint Followups to comp.lang.misc.