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



"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.


.



Relevant Pages

  • Re: while (1) vs. for ( ;; )
    ... >> difference in defect rate. ... Do you have some reason to think there's a significant ... > you read them, without paying much attention. ... > enough eye to catch these correctly? ...
    (comp.lang.c)
  • Re: while (1) vs. for ( ;; )
    ... >> difference in defect rate. ... > sharp enough eye to catch these correctly? ... Why not code it like you would read it in English: ...
    (comp.lang.c)