Re: while (1) vs. for ( ;; )



Tim Rentsch said:

> What Richard might be saying, but isn't really what I think
> he's trying to say, is that the control expression should
> redundantly express the condition for loop exit, even if the
> loop is never exited by the test on the loop control.

No, I'm saying I could put up with

for(;;)
{
fetch_microwave_command(&foo);
execute_microwave_command(&foo);
}

because it's quite evident that this is a genuinely "infinite" loop, in the
limited sense of that word applicable to a microwave oven!


> My first reaction was that he's meaning to say that loops
> that look infinite (but aren't) are bad,

All else being equal, yes...


> and the code should
> be reworked so that the loop control expression is really
> what controls the loop body.

....and yes.

(This reply is purely for clarification of my earlier intent - I did read
the rest of your article, and I accept that our viewpoints differ.)


--
Richard Heathfield
"Usenet is a strange place" - dmr 29 July 1999
http://www.cpax.org.uk
Email rjh at the above domain

.



Relevant Pages

  • Re: while (1) vs. for ( ;; )
    ... is that the control expression should ... >loop is never exited by the test on the loop control. ... I hope that's not what he's saying. ... Balmer Consulting ...
    (comp.lang.c)
  • Re: while (1) vs. for ( ;; )
    ... I would rather have the loop control ... > statement explicitly document the exit condition (unless there genuinely ... is that the control expression should ... loop is never exited by the test on the loop control. ...
    (comp.lang.c)
  • Re: while (1) vs. for ( ;; )
    ... >> be reworked so that the loop control expression is really ... >> what controls the loop body. ... are better with the exit condition in the loop body rather ...
    (comp.lang.c)
  • Re: Very Basic Performance Question
    ... "Rhino" scribbled on the stall wall: ... Your intuition is correct. ... the loop statement, storing its value in a temporary variable, unless there ... the control expression from within the loop. ...
    (comp.lang.java.programmer)
  • Re: Trying to use STRING
    ... that you do think 'what if', but as Richard says, it CANNOT happen. ... nothing to stop the group level field (ws-balanceX) being initialized ... "A loop-with-exit loop is a loop in which the exit condition ... one for initialization and the other for the inspect itself. ...
    (comp.lang.cobol)