[comp.lang.c] do-while construct

clt@pur-phy (Carrick Talmadge) (10/08/88)

Here is something I've always wondered about with regards to C.
Why is it that the syntax for do-while is

    do statement; while (expression) ;

rather than what I'd think would be more useful:

    do statement; while (expression) statement;

where "statement;" could of course be a compound statement.  I've seen
this more general construct in other languages, so it seems like it could
be done.  I'm curious to hear if anyone has heard a rationale for why it
was left out of the language.

Carrick Talmadge
clt@newton.physics.purdue.edu        
-------
The problem with this country is, if you shoot/hang/fire one bureaucrat,
they hire two more to take his place...

gwyn@smoke.ARPA (Doug Gwyn ) (10/08/88)

The
	loop	stuff
	until	condition
		more_stuff
	pool
construct is the most general form of loop.  It would be useful
if it were the ONLY loop construct in an Algol-like language.
However, C has several loop constructs for reasons of convenience,
and the exit from the middle of a loop is easily accomplished:
	for(;;) {
		stuff
	if(condition) break;
		more_stuff
	}
so that there is no real need to add such a construct.  Save it
for a new programming language (D?).