Re: Coding style: do_this(a,b) vs. do_this(a, b)

From: Albert Cahalan
Date: Tue Aug 17 2004 - 14:44:12 EST


On Tue, 2004-08-17 at 12:40, Pavel Machek wrote:
> Hi!
>
> > > Coding style document is not consistent with
> > > itself on whether there should be space after
> > > ","... This makes it standartize on ", " option.
> >
> > You can read it both ways, right? It's easy.
> > I can't even see the difference unless I'm
> > looking for it.
>
> Well, you maybe can't tell the difference, but I definitely can. You
> can read code aligned by two spaces, right?

Sure, but you can't mix that in the same file
with something else. Indentation and braces have
to be consistent. Other stuff matters far less.

> > We don't need any more bureaucracy.
> >
> > do_this(a,b); (1)
> > do_this(a, b); (2)
> > do_this (a,b);
>
> This looks extremely bad.
>
> > do_this (a, b);
> >
> > I can read them all. I might notice the space in
> > front of the '(', but I might not. Even putting a
> > space in front of the ';' isn't unreadable.
> >
> > People will pass laws until they are choked off,
> > unable to move without being in violation of some
> > silly little thing.
>
> I've seen people "fixing" code from (2) to (1), because they thought I
> prefer (1). (And I definitely don't). So yes, it is important.

Spaces are good for grouping things to increase readability.
So one might do this:

foo(a,b,c,d,e,f);
bar(a+b, a-b); // space needed for readability
baz(a,b, c,d); // suppose a and b logically go together, as do c and d
zzz(a==b && c==d); // common for an "if"

Slapping some arbitrary rule on top of this would
prohibit attempts to make things more readable.
Consider alignment between various lines when
calling similar functions:

foo(a, b+c, *q, *p);
bar(a, b+c, another, *q, *p);
baz(a, b, another, *q );

Sometimes it helps to see things neatly lined up
like that. Sometimes not, of course. The author
needs freedom to lay things out nicely when it matters,
while not concerning himself with trivial spacing
differences when it doesn't matter.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/