Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site spar.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!mtuxo!mtunh!mtung!mtunf!ariel!vax135!petsd!pesnta!amd!amdcad!decwrl!spar!freeman From: freeman@spar.UUCP (Jay Freeman) Newsgroups: net.lang.c Subject: C Programming Style -- New thought Message-ID: <418@spar.UUCP> Date: Tue, 23-Jul-85 21:13:36 EDT Article-I.D.: spar.418 Posted: Tue Jul 23 21:13:36 1985 Date-Received: Thu, 25-Jul-85 08:07:15 EDT Reply-To: freeman@max.UUCP (Jay Freeman) Organization: Schlumberger Palo Alto Research, CA Lines: 38 References: [Fools rush in where even the line-eater fears to tread] I find that one of the things that most affects my personal choice of program-formatting style is the number of lines on the console I work at. Most of my C coding is done sitting in front of old-style displays of 24 by 80 lines. I find it very valuable to be able to see all of a function (or at least all of a {} block) at once: Therefore, I favor styles such as if( (foo = bar( baz )) != ERR ) { ... /* style A */ over foo = bar( baz ); /* style B */ if( foo != ERR ) { ... when useful to save lines. If the lines saved by using style A instead of style B, make the difference between having all of a block on screen at once and not; then I consider the additional complexity of style A to be worth it. (And of course, there is ... foo = bar( baz ); if( foo != ERR ) { ... /* style C */ which I mention for completeness but consider a loser over (under?) style A.) My point is not to tell you all how to do it, but merely to emphasize that screen size imposes a tradeoff among different sources of incomprehensibility. A related issues is whether it is "worth it", in the same tradeoff, to have an extra line for '{' or for '}'. (My personal opinion is "no" for the former and "yes" for the latter.) Incidentally, I avoid printouts wherever possible in developing code: I use them only when I cannot get to a terminal for some reason -- I cannot imagine circumstances in which my preference would be the other way around. (Well, maybe 300 baud ...) -- Jay Reynolds Freeman (Schlumberger Palo Alto Research)(canonical disclaimer)