Path: utzoo!attcan!uunet!sco!seanf From: seanf@sco.COM (Sean Fagan) Newsgroups: comp.lang.c Subject: Re: For vs while (was Re: Comparing strings...) Message-ID: <8308@scolex.sco.COM> Date: 20 Oct 90 09:18:39 GMT References: <2205.271700c2@cc.nu.oz.au> <1990Oct13.190106.15615@ux1.cso.uiuc.edu> <10678.271ade27@amherst.bitnet> <1990Oct17.030157.460@ux1.cso.uiuc.edu> <2226@ukc> Sender: news@sco.COM Reply-To: seanf (Sean Fagan) Organization: The Santa Cruz Operation, Inc. Lines: 30 In article <2226@ukc> tlg@ukc.ac.uk (T.L.Goodwin) writes: >Almost, but not quite. If the body of the loop contains a "continue", >then the second example becomes an infinite loop (other changes to i >and "break"s notwithstanding), since the increment is never reached. #define while(cond) for(;cond;) (I'm sitting here trying to think of any case where this will break [no pun intended 8-)] something; I can't think of any, offhand.) If you have something such as while () { whatever; } this will be an infinite loop given the macro, but a syntax error otherwise. But that's all I can think of... (I've wondered why C had while, because of this. The only think I could think of was that for came after while, and They didn't want to break existing code... Any commentators? [Henry? Chris? Doug? Dennis?]) -- -----------------+ Sean Eric Fagan | "*Never* knock on Death's door: ring the bell and seanf@sco.COM | run away! Death hates that!" uunet!sco!seanf | -- Dr. Mike Stratford (Matt Frewer, "Doctor, Doctor") (408) 458-1422 | Any opinions expressed are my own, not my employers'.