From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Hohensee Message-Id: <200108180447.AAA10603@smarty.smart.net> Subject: Re: [9fans] Sam question To: 9fans@cse.psu.edu In-Reply-To: <20010817223532.73AB8199F3@mail.cse.psu.edu> from "David Gordon Hogan" at Aug 17, 2001 06:35:27 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 18 Aug 2001 00:47:30 -0400 Topicbox-Message-UUID: e24baf00-eac9-11e9-9e20-41e7f4b1d025 > > > I hear this argument from Gnuers and the like. If it's a problem, > > your identifiers are too long or your functions are too long (thus > > your block nesting is too deep). In the case of Gnu code, both are > > true. > > Another common reason is that people don't know how to use continue. > Eg, instead of writing: > > for(p = example; p != nil; p = p->next) { > q = p->fish; > if(q->foo > 4 && q->bar < 3) { > r = q->blarg; > if(r->foo == 7) { > dosomething(r); > r->done++; > } > } > } > > it is stylistically preferable to write > > for(p = example; p != nil; p = p->next) { > q = p->fish; > if(q->foo <= 4 || q->bar >= 3) > continue; > r = q->blarg; > if(r->foo != 7) > continue; > dosomething(r); > r->done++; > } > > Notice the difference this makes in the indentation. > I think it's also slightly more readable, but YMMV. > Very interesting, since I don't use continue myself that I can recall. The above technique is limited to "trailing ifs" though isn't it? i.e. it won't work with... for (p = example; p != nil; p = p->next) { q = p->fish; if(q->foo > 4 && q->bar < 3) { r = q->blarg; } r->done++; } i.e. where the if to continuefy is not the last thing in the enclosing block? Rick Hohensee www.clienux.com