Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!uflorida!novavax!twwells!bill From: bill@twwells.uucp (T. William Wells) Newsgroups: comp.lang.c Subject: Suggested new C loop syntax (was `if (a = b)') Message-ID: <264@twwells.uucp> Date: 22 Dec 88 01:46:35 GMT References: <5@rsoft.UUCP> <1071@goofy.megatest.UUCP> <861@quintus.UUCP> <3049@arcturus> <2485@ficc.uu.net> Reply-To: bill@twwells.UUCP (T. William Wells) Organization: None, Ft. Lauderdale Lines: 35 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <2485@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: : In article <3049@arcturus>, evil@arcturus.UUCP (Wade Guthrie) writes: : > In article <8536@alice.UUCP>, ark@alice.UUCP (Andrew Koenig) writes: : > > do ch = getchar(); : > > while (ch != EOF) : > > process(ch); : > > or, with braces: : > > do { : > > ch = getchar(); : > > } while (ch != EOF) { : > > process(ch); : > > } : : This is a wonderful and clean extension to 'C' that solves the loop problem : once and for all! This is a bad syntax. Why? Because of this: do statement while (expr); statement See the difference? Well, in case you didn't, it is the semicolon at the end of the while expression. This is damned hard to spot and does not lead to a syntax error. I'll stick to using a break. --- Bill {uunet|novavax}!proxftl!twwells!bill