Donn Cave <donn at u.washington.edu> wrote:
>I sort of regret wasting bandwidth on this purely academic question,
>but it's a matter of truly venerable tradition that C's loop is a
>bit shy of perfection. The idea as I understand it, is that there
>are essentially two control points in a loop, the entry, and the
>conditional repeat. C conflates those two in one, because both
>entry and the conditional repeat have to be at the "top".
I didn't suggest it was perfect, just that I liked it.
<snip>
>People who claim that C fixes this just expose the limitations of
>their thinking. C does not fix this, by allowing an assignment
>there, except in the restricted case where the pre-conditional
>part of the loop can fit into one expression. (Note that I'm not
>talking about the initialization section of for(), which is a
>pure non-feature - those statements can just as well be written
>before the loop.)
Not so. It can avoid an extra enclosing block in cases such as:
if (x==y)
for (initialise loop; ....)
do something
Which is less fussy than
if (x==y)
{ initialise loop
for (....)
do something
}
--
Dale Strickland-Clark
Riverhall Systems Ltd