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

Peter da Silva peter at ficc.uu.net
Tue Mar 20 04:03:47 AEST 1990


In article <383 at bohra.cpg.oz>, ejp at bohra.cpg.oz (Esmond Pitt) writes:
> In article <OVB2S3Bxds13 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
> >The only sense in which repeat...until is more natural than do...while is

> There is a further significant difference between the Pascal
> repeat..until and the 'C' do..while. In Pascal, 'repeat..until'
> delimits a statement-list, not a single statement as in 'C'.

Oh, granted. But that's not the issue at hand, is it? Pascal could have
had a do-while with the same gross semantics as repeat-until, and C
could have had a repeat-until with the same gross semantics as do-while.
That's a side effect of C's strict insistence on statement blocks being
explicit, where Pascal allows begin, or both, to be implicit.

In Pascal++ (a language I made up at this very moment) you have a new
control structure, do-while. It has the same semantics as repeat-until
except that the sense of the test is reversed. The main difference between
repeat-until and do-while is that it's marginally harder to generate
code for the do-while...

In C^.D (a language I made up at this very moment) you have a new control
structure, repeat-until. It has the same semantics as do-while expect that
the sense of the comparison is reversed. The main difference between repeat-
until and do-while is, um... I don't think there is one. We already have
the code to generate two sorts of branches for the do-while.

#define repeat do
#define until(x) while(!(x))
-- 
 _--_|\  `-_-' Peter da Silva. +1 713 274 5180. <peter at ficc.uu.net>.
/      \  'U`
\_.--._/
      v



More information about the Comp.lang.c mailing list