lkml.org 
[lkml]   [2003]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] CodingStyle fixes for drm_agpsupport
Jeff Garzik wrote:
> Also, having two styles
> of 'if' formatting in your example just screams "inconsistent" to me :)

Naw, it's only one style:

<stmt> ::= if (<expression>) <stmt>
<stmt> ::= { <newline> <stmts> } <newline>
<stmt> ::= <expression> ; <newline>
etc.

Perfectly consistent. ("Always end a statement with a newline.")

> Ug. The first and last 'if' need spreading out away from the big fat
> block,

Why waste a perfectly good punch card on that second line ? :-)

My own formatting rules for "if" go about like this:

1) if "if" and the statement fit on a single line, put them accordingly
("vertical space is precious")

2) if the line needs to wrap (I wrap at the 79th column), always put
the statement on a separate line, fully indented ("wrap at the
highest hierarchical level")

3) likewise for "else" and statement. Here, 2) doesn't apply for kernel
code, which uses a full tab for indentation - in my user-space code,
I use only four spaces, so sometimes, I get
else
stuff_that_just_happens_to_be_too_long_by_one_silly_little_character();

4) if the statement is a block, and there is an "else" branch with a
single statement, invert the condition ("don't hide the fine print")

Since I'm the only sentient being in the universe, and all the rest
of you are just figments of my imagination, it's fairly obvious that
my style is The Right Style :-)

> and the "return (whatever)" fools your eyes into thinking they
> are function calls at a 10-nanosecond glance.

Yeah, I hate that too.

Larry:
> > I also make people do
> >
> > if ((a <= B) || (c >= d)) {

Argl. That's one place where the precedence works beautifully.
Extra parentheses in trivial cases always make me suspect that
the author was actually trying to do something else.

- Werner

--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:47    [W:0.080 / U:0.812 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site