Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site umd5.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!umcp-cs!cvl!umd5!zben From: zben@umd5.UUCP Newsgroups: net.lang.c Subject: Re: C Indentation Survey Results (long...) Message-ID: <497@umd5.UUCP> Date: Tue, 7-May-85 13:45:59 EDT Article-I.D.: umd5.497 Posted: Tue May 7 13:45:59 1985 Date-Received: Thu, 9-May-85 01:46:38 EDT References: <9930@brl-tgr.ARPA> <381@busch.UUCP> <5497@utzoo.UUCP> <5557@utzoo.UUCP> <1472@orca.UUCP> Reply-To: zben@umd5.UUCP (Ben Cranston) Organization: U of Md, CSC, College Park, Md Lines: 43 Summary: A much better indentation of the example referenced. Now, isn't this rendition of the example given earlier **MUCH** easier to read, parse, and understand?... switch (key) { case BACK: fprintf(stoout,"BACK\n"); if (device->s.stroke.current_editpos > 1) { device->s.stroke.current_editpos--; for ( device->s.stroke.editptr = &(device->s.stroke.header), i = 1; device->s.stroke.editptr->next->next, i < device->s.stroke.current_editpos; device->s.stroke.editptr = device->s.stroke.editptr->next, i++ ) { /* NADA */ } } Note: Braces on new line, indented by one, with code indented by another two. Continued statements indented to level of original statement. Perhaps something could be done to separate the FOR clauses that end with comma from the FOR clauses that end with semicolon. I haven't been programming C long enough to have done enough of these complex statements to have evolved a programming style for them. Now, come on. K., R., et al done did something really neat in coming up with C and Unix, but they don't walk on water nor were they a result of virgin birth. They did an awful lot of things right, and they did a few things very very wrong. Making tab stops every eight was very very wrong. I'm sure they didn't waste a lot of time thinking about it, they just had a bunch of DEC hardware around and decided to use what they had. Note if you were to trivially modify the above to indent 1 and 3 rather than 1 and 2, every other indent would line up with a tab stop and you could (sort of) have the best of both worlds. And (as long as we are sharpening axes here) if you were programming in PASCAL you could put the sucker in a WITH DEVICE clause and get rid of all those "device->" references. AND, it would be more efficient since the reference would only be evaluated once, at the WITH clause (clearly compiler optimization in C compilers would have a bearing on this). -- Ben Cranston ...{seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben zben@umd2.ARPA