Re: while (1) vs. for ( ;; )
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 31 Aug 2005 05:18:31 GMT
"Charlie Gordon" <news@xxxxxxxxxxx> writes:
> "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 ?
Any code that declares a variable called "l" has worse problems than
while() vs. for().
In well-written code, something that looks like "while (1)" *is*
"while (1)"; I don't have to waste my time distinguishing between '1'
and 'l'.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: while (1) vs. for ( ;; )
- From: Charlie Gordon
- 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
- Re: while (1) vs. for ( ;; )
- From: Charlie Gordon
- while (1) vs. for ( ;; )
- Prev by Date: Re: Code consolidation
- Next by Date: Re: while (1) vs. for ( ;; )
- Previous by thread: Re: while (1) vs. for ( ;; )
- Next by thread: Re: while (1) vs. for ( ;; )
- Index(es):
Relevant Pages
|