new do-while syntax

Blair P. Houghton bph at buengc.BU.EDU
Fri Dec 23 03:24:21 AEST 1988


In article <1963 at scolex> seanf at sco.COM (Sean Fagan) writes:
>In article <1716 at buengc.BU.EDU> bph at buengc.bu.edu (Blair P. Houghton) writes:
[in response to:]
>>>>In article <8536 at alice.UUCP>, ark at alice.UUCP (Andrew Koenig) writes:
>>But what's wrong with [the following code]?
>>	do {
>>		process(ch);
>>		process2(ch);
>>		process3(ch);
>>	} while (
>>		ch = getchar(),
>>		ch &= MASK,
>>		ch  = table_look_up[ch],
>>		report_status(ch),
>>		ch != EOF
>>	);
>
>Uhm, little thinks like the fact that quite a few compilers will generate
>the equivalent of:

[...broken code deleted...]
Buy yerself a new compiler.  This one's screwed.

[...optimization of broken code deleted quickly...]
>Also, ch is not initialized to the getchar(), which it was in the initial
>example (which I deleted, of course), and the code looks horrible.

I happen to think it looks just fine; the usage of "(" and ");" parallels
the usage of "{" and "}", and the comma is akin to a sort of sub-semicolon.
(Will the Semanticists please put away those rotten vegetables?  Thank you.)

It Just Ain't C.

>Is that enough?

No, you forgot to impugn my ancestry.

And to mention that statement is not expression, expression is not
statement.  The example above is not complete by any means, and will
break if I try to put a "for(expr;expr;expr);," in the middle of the
while-block.

				--Blair
				  "...something about..."



More information about the Comp.lang.c mailing list