Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!calvin!johns From: johns@calvin.EE.CORNELL.EDU (John Sahr) Newsgroups: comp.lang.c Subject: Re: new do-while syntax (Re: `if (a = b)'...) Message-ID: <864@calvin.EE.CORNELL.EDU> Date: 18 Dec 88 20:37:02 GMT References: <5@rsoft.UUCP> <1071@goofy.megatest.UUCP> <861@quintus.UUCP> <8536@alice.UUCP> <3049@arcturus> Reply-To: johns@calvin.ee.cornell.edu.UUCP (John Sahr) Organization: Cornell Space Plasma Physics Group Lines: 50 In article <3049@arcturus> evil@arcturus.UUCP (Wade Guthrie) writes: >In article <8536@alice.UUCP>, ark@alice.UUCP (Andrew Koenig) writes: [suggesting a do-while syntax with the loop test in the middle] >> do { >> ch = getchar(); >> } while (ch != EOF) { >> process(ch); >> } [deletions] > ..........., but the above constructions >are EXCEEDINGLY hard to read. I much perfer the method which already >exists: > > while ( (c=getchar()) != EOF) > process(c); >Wade Guthrie I think the point of Mr. Koenig's proposal was to handle larger loops than the literal interpretation of his example indicated. Consider >> do { >> ch = getchar(); ch &= MASK; ch = table_look_up[ch]; report_status(ch); >> } while (ch != EOF) { >> process(ch); process2(ch); process3(ch); >> } This too, is contrived, but is cleaner than jamming a bunch of statements masquerading as an exit condition inside the test. I'm not thrilled about the syntax, but it is an interesting idea. It adds no keywords, breaks no code, resembles if-else syntax, and would solve some "artistic style" problems I run into. Of course, one could use goto-labels, breaks, or that interesting switch-case-for loop that showed up in this group a while back. Actually, my main objection with the syntax, I realize, is only the indent/brace style, which differs from my own. (I won't tread any further along that path...:-) ) Happy Holidays, John -- John Sahr, School of Elect. Eng., Upson Hall Cornell University, Ithaca, NY 14853 ARPA: johns@calvin.ee.cornell.edu; UUCP: {rochester,cmcl2}!cornell!calvin!johns