Path: utzoo!attcan!uunet!jarthur!usc!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.lang.c Subject: Re: do...while vs. repeat...until (was: Errors aren't that simple) Message-ID: Date: 19 Mar 90 18:03:47 GMT References: <16188@haddock.ima.isc.com> <9130009@hpavla.AVO.HP.COM> <383@bohra.cpg.oz> Organization: Xenix Support, FICC Lines: 28 In article <383@bohra.cpg.oz>, ejp@bohra.cpg.oz (Esmond Pitt) writes: > In article peter@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. . / \ 'U` \_.--._/ v