X-Received: by 10.66.82.103 with SMTP id h7mr261743pay.11.1355827259030; Tue, 18 Dec 2012 02:40:59 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!kr7no9711912pbb.0!news-out.google.com!6ni51265pbd.1!nntp.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 18 Dec 2012 04:40:57 -0600 Message-ID: <50D04837.3186@mindspring.com> Date: Tue, 18 Dec 2012 05:40:55 -0500 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: comma in a c statement, ie for(i=0,i2=0;i<10;i++,i2) References: <87hanlj6yl.fsf@bazspaz.fatphil.org> <874njkjskj.fsf@bazspaz.fatphil.org> <50CFB97C.3988@mindspring.com> <0.3d0bd95e6186d1006003.20121218013242GMT.87a9tcb0w5.fsf@bsb.me.uk> <50CFCC9D.2D2A@mindspring.com> Lines: 59 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.218.89 X-Trace: sv3-mUfD0GryKb2EiLuBLxzXICHG9Z9Gh2fLwuShA9W22j/MtJT5vHo6Py/X4kF5WskOZCeoDBF60Z8sOIE!AYD/eWAUGs/32MCFK5rniHhh+DTnrVZqeuK1pfkRqtbUHQshM5yC6Bzred1AdkRJxcnuTOvrsA0i!PpgcaHAdzQ== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3155 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Xref: csiph.com comp.lang.c:29458 James Kuyper wrote: > > On 12/17/2012 08:53 PM, pete wrote: > > Ben Bacarisse wrote: > >> > >> pete writes: > >> > >>> Phil Carmody wrote: > >>>> Phil Carmody writes: > >>>>> This reinforces something that I've spotted historically > >>>>> - there seems to be some strange fetish > >>>>> for using the swiss-army for(;;) > >>>>> where while() is perfectly suitable. > >>>> > >>>> Perhaps I should have worded those as just > >>>> "for" and "while", I wasn't > >>>> trying to imply the "(;;)" part, just the iteration statements. > >>> > >>> for (;;) is special. > >>> > >>> while () , doesn't compile, > >>> even though K&R 3.5 says that they are equivalent. > >> > >> That's a very odd reading of the text! > >> I've tried a few times and I > >> can't get that meaning from what's written in my K&R. > > > > The for statement > > > > for (expr1; expr2; expr3) > > statement > > > > is equivalent to > > > > expr1; > > while (expr2) { > > statement > > expr3; > > } > > > > except for the behavior of continue, which is described in 3.7. > > There's a few other differences, > the relevant one in this context being > that expr2 is optional if a for() statement, > but mandatory in a while() > (6.8.5p1). > Also, what you've called expr1 is called clause-1 in the standard, to > reflect the fact that it can be either an expression or a declaration. > If it is a declaration, any identifiers it declares have a scope that > includes the entire for() statement, but does not extend to the > enclosing block, so you should enclose your 'while' replacement in {}, > to give those identifiers the right scope. I was talking about what K&R says and then quoting K&R in response to Ben Bacarisse. -- pete