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



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



Relevant Pages

  • Re: while (1) vs. for ( ;; )
    ... > difference in defect rate. ... Do you have some reason to think there's a significant ... sharp enough eye to catch these correctly? ... That way anything that looks like whilewill catch my eye, ...
    (comp.lang.c)
  • Re: The Anti Alts who have been here for years.
    ... any kind of attention will do. ... being the true reason. ... naively posted some pro Homeopathy comments. ... feel THREATENED by almost any alternative medicine ...
    (misc.health.alternative)
  • Re: HEADSUP usb2 (usb4bsd) to become default in 2 weeks.
    ... on Jan 3rd I will switch the GENERIC kernel to use ... is there any reason why this needs to be rushed in over the ... developer attention and updates (and yeah there might be painful ... and the milestones to take and open items. ...
    (freebsd-current)
  • Re: Quitting 3.5
    ... that have absolutely no reason to let the fights be anything like fair. ... And the immediate lieutenant is not paying attention to ... the gang of trouble-seekers that we call an adventuring party doesn't ... Sauruman the White, Maiar and wizard ...
    (rec.games.frp.dnd)
  • Re: Geraldine Ferraro, WTF?
    ... race has something to do with the attention he's been receiving. ... African American certainly has something to with all the attention he's ... been receiving - it's not the only reason obviously since he's a smart ...
    (rec.sport.football.college)