gwyn@smoke.BRL.MIL (Doug Gwyn ) (12/06/88)
In article <9125@rpp386.Dallas.TX.US> jfh@rpp386.Dallas.TX.US (The Beach Bum) writes: >I have one MAJOR gripe with the above { } scheme. Consider: >main () >{ > if (expr) > { But that's not the scheme I recommended. I also indent the braces for the body of a function. Basically, controlled statements are indented. To be 100% consistent there should be yet another indent after {, but that's too much indentation even for me. >Henry is too god. But is he too god to be true? That is the question.
decot@hpisod2.HP.COM (Dave Decot) (12/06/88)
> NO, THIS IS HOW YOU DO IT. It's the only way :-) ! > > main (argc, argv) > int argc; > char *argv[]; > { > int foo; > char bar; > > if (expr) > { > while (cond) > { > } > } > } 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
mark@UNIX386.Convergent.COM (Mark Nudelman) (12/16/88)
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
randy@uokmax.UUCP (Longshot) (12/17/88)
In article <212@UNIX386.Convergent.COM> mark@UNIX386.Convergent.COM (Mark Nudelman) writes:
^
^3. Space before and after arithmetic operators (+,-,*,/,%,>>,&,|, etc.)
^
As an interesting aside, the cc here on our Multimax will generate warnings for
lines like:
x=-y; /* x = -y or x =- y? */
In other words, and math operator that can be combined with = can produce an
error. This will happen with +,-, *, and any others that fit the bill. Now, I
have yet to hard-test it to see which case it generates. Has anyone had
similiar messages, and checked further?
Randy
--
Randy J. Ray University of Oklahoma, Norman, Oklahoma
!texsun!uokmax!randy randy@uokmax.uucp randy@uokmax.ecn.uoknor.edu
Morality is meaningful only in the culture within it exists. -instructor
{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][}{][