Path: utzoo!attcan!uunet!nuchat!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.lang.c Subject: Re: `if (a = b)' (was Standard indentation?) Message-ID: <2485@ficc.uu.net> Date: 18 Dec 88 06:06:55 GMT References: <5@rsoft.UUCP> <1071@goofy.megatest.UUCP> <861@quintus.UUCP> <3049@arcturus> Organization: SCADA Lines: 51 In article <3049@arcturus>, evil@arcturus.UUCP (Wade Guthrie) writes: > The sound of a programmer trying to read a C program flinging himself > against a wall. Is that like the sound of one hand clapping? > 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! > I really do not mean to flame this person, but the above constructions > are EXCEEDINGLY hard to read. I much perfer the method which already > exists: Only if you're not used to it. have you ever done extensive bourne-shell or Forth programming, where this construct is a common idiom? > while ( (c=getchar()) != EOF) > process(c); How about (in K&R indenting style, for consistancy): do { Ask question. Get answer. Categorise answer. } while(answer != exit) { Stuff... switch(answer) { ... } And more stuff... } That is, what about the case where the first part of the loop is too complex to fit in a while statement. Sure, you could put a break in, but isn't this clearer? The existing while and do loops become special cases. -- Peter da Silva, Xenix Support, Ferranti International Controls Corporation. Work: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180. Home: bigtex!texbell!sugar!peter, peter@sugar.uu.net.