do...while vs. repeat...until (was: Errors aren't that simple)
Karl Heuer
karl at haddock.ima.isc.com
Fri Mar 16 09:58:42 AEST 1990
In article <5819.25f7a840 at vax1.tcd.ie> cbuckley at vax1.tcd.ie writes:
>In article <Mar.7.10.43.42.1990.17402 at paul.rutgers.edu>, emuleomo at 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 at ima.ima.isc.com or harvard!ima!karl), The Walking Lint
Followups to comp.lang.misc.
More information about the Comp.lang.c
mailing list