do...while vs. repeat...until (was: Errors aren't that simple)

Gary Jackoway gary at hpavla.AVO.HP.COM
Sat Mar 17 06:12:04 AEST 1990


Karl Heuer writes:

> 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.

----------

Bah, humbug.
It is clearly more consistent to have while..do and do..while where the
sense of the test works the same, than while..do and repeat..until
where the sense of the test changes.  If nothing else, when someone converts
one form into the other, the likelihood of error is significantly reduced.
And it seems to come up frequently that one has to change the test from
the beginning to the end of the loop. (And vice-versa.)

Gary "and I learned Pascal before C" Jackoway



More information about the Comp.lang.c mailing list