Re: while (1) vs. for ( ;; )
- From: "Charlie Gordon" <news@xxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 02:23:15 +0200
"Keith Thompson" <kst-u@xxxxxxx> wrote in message
news:lnu0h7qh5r.fsf@xxxxxxxxxxxxxxxxxx
> Tim Rentsch <txr@xxxxxxxxxxxxxxxxxxx> writes:
> > pete <pfiland@xxxxxxxxxxxxxx> writes:
>
> I won't try to speak for pete, but since "while (1)" and "for (;;)"
> are semantically identical, I'd be very surprised if there were any
> difference in defect rate. It's something that seems so obvious to me
> that I wouldn't bother trying to measure it without a very good
> reason. If there were a difference, I'd tend to assume that it's a
> difference in training (perhaps the books or classes that use one form
> happen, by coincidence to be better than the ones that use the other
> form). Do you have some reason to think there's a significant
> difference?
Assume the programmer always uses while(1) { ... } for his endless loops.
You quickly get used to interpreting these automatically as you read them,
without paying much attention.
What if there are some while(l) { ... } loops as well. Will you always keep a
sharp enough eye to catch these correctly ?
I prefer for(;;). That way anything that looks like while(l) will catch my eye,
and I will no doubt complain about such a poor choice for a variable name.
Therefore, I agree while(1) is more prone to indirectly causing defect than
for(;;).
Chqrlie.
.
- Follow-Ups:
- Re: while (1) vs. for ( ;; )
- From: Keith Thompson
- Re: while (1) vs. for ( ;; )
- From: Baxter
- Re: while (1) vs. for ( ;; )
- References:
- while (1) vs. for ( ;; )
- From: Michael B Allen
- Re: while (1) vs. for ( ;; )
- From: Tim Rentsch
- Re: while (1) vs. for ( ;; )
- From: pete
- Re: while (1) vs. for ( ;; )
- From: Tim Rentsch
- Re: while (1) vs. for ( ;; )
- From: Keith Thompson
- while (1) vs. for ( ;; )
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: More questions about casting function pointers ..
- Previous by thread: Re: while (1) vs. for ( ;; )
- Next by thread: Re: while (1) vs. for ( ;; )
- Index(es):
Relevant Pages
|