From: | Hans Aberg <haberg-news@telia.com> |
Newsgroups: | comp.compilers |
Date: | Mon, 10 Jan 2011 10:26:02 +0100 |
Organization: | A noiseless patient Spider |
References: | 10-12-040 10-12-043 11-01-005 11-01-025 |
Keywords: | syntax, design |
Posted-Date: | 12 Jan 2011 00:15:37 EST |
On 2011/01/06 21:45, George Neuner wrote:
> Why do so many languages offer (at least) two forms of conditional
> loop: one with the test at the beginning and another with the test at
> the end? Why not just offer an infinite loop and a way to break out
> that can be tied to any conditional?
The reason for the different forms is merely that they help structuring
code in common programming.
Semantically, the C form
do a while ( p ) ;
is equivalent to
while (a, p) ;
but the latter is less expressive. And
while ( p ) a;
is equivalent to
for (; p;) a;
Return to the
comp.compilers page.
Search the
comp.compilers archives again.