Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!oliveb!pyramid!ctnews!UNIX386!mark From: mark@UNIX386.Convergent.COM (Mark Nudelman) Newsgroups: comp.unix.wizards Subject: Re: braces (was: Latest indent request) Message-ID: <212@UNIX386.Convergent.COM> Date: 15 Dec 88 23:16:14 GMT References: <9076@smoke.BRL.MIL> <14020049@hpisod2.HP.COM> Organization: Convergent Technologies, San Jose, CA Lines: 72 In article <14020049@hpisod2.HP.COM>, decot@hpisod2.HP.COM (Dave Decot) writes: > So close! However, this really should be: > > main (argc, argv) > int argc; > char *argv[]; > { > int foo; > char bar; > > if (expr) > { > while (cond) > { > } > } > } > > Dave Decot > hpda!decot Oh, you *almost* got it! It's really supposed to be like this: main(argc, argv) int argc; char *argv[]; { int foo; char bar; if (expr) { while (cond) { } } else if (expr) { switch (expr) { case 0: break; default: break; } } else { func(0); } return (1); } While we're arguing style religion, there are of course many other issues besides indentation and braces. Altho it would seem that there aren't many possibilities, I often find I can identify the author of a piece of code simply by the spacing/indentation style. This is what I use: (Anyone else caught using it will be prosecuted :-) 1. One space between if/while/return and the left parenthesis. (And the expr after return must be surrounded by parentheses.) 2. No space between function name and the left parenthesis. 3. Space before and after arithmetic operators (+,-,*,/,%,>>,&,|, etc.) 4. Two spaces after each semicolon in a for statement; e.g. "for (i = 0; i < MAX; i++)" 5. /* * Comments go like this, with the same indentation * as the code they describe. */ For some reason, code which doesn't follow 1 and 2 really annoys me. Mark Nudelman {sun,decwrl,ihnp4!hplabs}!pyramid!ctnews!UNIX386!mark