Re: while (1) vs. for ( ;; )
- From: Christian Bau <christian.bau@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 00:02:49 +0100
In article <kfnu0h78bb1.fsf@xxxxxxxxxxxxxxxxxxx>,
Tim Rentsch <txr@xxxxxxxxxxxxxxxxxxx> wrote:
> However, I don't believe that all "infinite-but-not-really"
> loops benefit from this kind of rewriting. Even for loops
> with only one exit condition, sometimes having the only loop
> exit be a break (or return) in the middle of the loop body
> is the clearest expression of what the loop is supposed to
> do. At least, that has been my experience.
Example:
for (;;) {
/* Quite a bit of code to find the next candidate */
if (no more candidates) break;
/* Check if this candidate can be ignored */
if (candidate can be ignored) continue;
/* Do the real work */
do_some_work ();
}
You can easily change this into "structured" code, but it doesn't
improve it.
.
- References:
- while (1) vs. for ( ;; )
- From: Michael B Allen
- Re: while (1) vs. for ( ;; )
- From: Richard Heathfield
- Re: while (1) vs. for ( ;; )
- From: Tim Rentsch
- while (1) vs. for ( ;; )
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: Re: confused abt file operations
- Previous by thread: Re: while (1) vs. for ( ;; )
- Next by thread: Re: while (1) vs. for ( ;; )
- Index(es):
Relevant Pages
|