Article View: comp.lang.misc
Article #882Re: do...while vs. repeat...until (was: Errors aren't that simple)
From: Patrick M. Ryan
Date: Fri, 16 Mar 1990 13:57
Date: Fri, 16 Mar 1990 13:57
30 lines
1952 bytes
1952 bytes
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 <Mar.7.10.43.42.1990.17402@paul.rutgers.edu>, 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
Technical Details
Message-ID:
<1990Mar16.135706.28432@sjuphil.uucp>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mailrus!cs.utexas.edu!usc!rutgers!bpa!sjuphil!ryanReferences:
<8192@hubcap.clemson.edu> <17000003@hpcvra.CV.HP.COM> <Mar.7.10.43.42.1990.17402@paul.rutgers.edu> <5819.25f7a840@vax1.tcd.ie> <16188@haddock.ima.isc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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> <Mar.7.10.43.42.1990.17402@paul.rutgers.edu> <5819.25f7a840@vax1.tcd.ie> <16188@haddock.ima.isc.com> Reply-To: ryan@sjuphil.UUCP (Patrick M. Ryan) Organization: SJU Grad CSC Lines: 30