Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.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:48:04 -0600 Message-ID: <50D049E0.78C5@mindspring.com> Date: Tue, 18 Dec 2012 05:48:00 -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> <0.d3d5ff8b39c0ee47e50b.20121218022900GMT.874njkayab.fsf@bsb.me.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 61 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.218.89 X-Trace: sv3-k1yKBvkuV7rau82rXGI2yiD89HAAWYRqAaOWGEumWzmOrfV8gzuNFtzPXVEUMuDPK7VEh+3R097eVqc!CnaabElPNhno6TJq4w97q501b5wzUy4uhURMgtGW0x0lRyHA2ngEHsuexgBtUPfQQ8ISSfOKQRLm!KTsbK2q1uQ== 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: 3429 Xref: csiph.com comp.lang.c:29459 Ben Bacarisse wrote: > > pete writes: > > > 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. > > Does it not go on to explain what happens when any/all of expr[123] are > missing? Mine does. > > Even if you stopped there and chose to ignore the sentences that follow, > I don't see how you can conclude that the equivalence applies to "for > (;;)". You'd have to be sure that expr[123] can be "empty" and that's > not at all clear. We've been told about expressions in chapter 2, but > none of the have been "empty". We are told, right away, that it's > possible to omit these parts of the for loop, but the special meaning is > explained then and there in the sentences that explain that they can be > omitted. If 3.5 had said that Superman and his sister were equivalent except that Superman was a male, as described in 3.7. and then the text said that Superman had x-ray vision, I would take that to mean that Supergirl had x-ray vision too. -- pete