Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site andromeda.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!genrad!panda!talcott!harvard!seismo!columbia!topaz!andromeda!dave From: dave@andromeda.UUCP (Dave Bloom) Newsgroups: net.lang.c Subject: Re: C bites / programming style Message-ID: <35@andromeda.UUCP> Date: Mon, 9-Sep-85 10:35:06 EDT Article-I.D.: andromed.35 Posted: Mon Sep 9 10:35:06 1985 Date-Received: Wed, 11-Sep-85 07:42:30 EDT References: <418@phri.UUCP> <700002@fthood> <209@3comvax.UUCP> <735@umd5.UUCP> Organization: Rutgers University, Newark, N.J. Lines: 47 In article <735@umd5.UUCP>, zben@umd5.UUCP writes: > Actually, I prefer: > > if (condition) > { > s1; > s2; > } > > If I had to rationalize, I would say that the { and } are intermediate in > level between the mainline code and the controlled statements, and that their > indenting reflects this intermediate status. Also, you can draw lines on the > listing between the brackets and manually verify nesting status. This seems > very useful, as the C compilers I have used don't seem to be very good at > giving meaningful diagnostics in this case. I have seen programs written in this style, and find them terribly confusing to read because there are just too many levels of indentation to the eye. Also, if you are working on a bogus editor, indenting with anything other than tabs becomes a chore. I prefer: if(some condition) { A statement; Another Statement; Some Garbage; } while(another condition) { etc; etc; } This does a few things: For starters, the opening brace does not occupy a line of its own, which makes the code a lot more compact from a visual point of view. 2) The closing brace is in line with the indented code, and serves as a terminator much as a ';', 3) The closing brace really shouldn't be in line with the if, because it is PART of the if statement and should be represented as such. You should be able to read down the program and see each statement on its own indentation level without the clutter of closing braces. -- ------------------------------------------------------------------------------- allegra\ Dave Bloom harvard \ pyramid\ seismo \ pyrnj >!andromeda!dave HOME: (201) 868-1764 ut-sally >!topaz/ WORK: (201) 648-5083 sri-iu / ihnp4!packard / "You're never alone with a schizophrenic...."