public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Coding style: do_this(a,b) vs. do_this(a, b)
@ 2004-08-17 10:38 Pavel Machek
  2004-08-17 21:09 ` Fao, Sean
  2004-08-17 21:59 ` Frank van Maarseveen
  0 siblings, 2 replies; 10+ messages in thread
From: Pavel Machek @ 2004-08-17 10:38 UTC (permalink / raw)
  To: kernel list, Andrew Morton

Hi!

Coding style document is not consistent with itself on whether there
should be space after ","... This makes it standartize on ", " option.

								Pavel

--- tmp/linux/Documentation/CodingStyle	2004-05-20 23:08:01.000000000 +0200
+++ linux/Documentation/CodingStyle	2004-06-06 00:27:11.000000000 +0200
@@ -356,11 +356,11 @@
 
 Macros with multiple statements should be enclosed in a do - while block:
 
-#define macrofun(a,b,c) 			\
+#define macrofun(a, b, c) 			\
 	do {					\
 		if (a == 5)			\
-			do_this(b,c);		\
-	} while (0)
+			do_this(b, c);		\
+	} while(0)
 
 Things to avoid when using macros:
 

-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Coding style: do_this(a,b) vs. do_this(a, b)
@ 2004-08-17 11:51 Albert Cahalan
  2004-08-17 16:07 ` Alexander Nyberg
  2004-08-17 16:40 ` Pavel Machek
  0 siblings, 2 replies; 10+ messages in thread
From: Albert Cahalan @ 2004-08-17 11:51 UTC (permalink / raw)
  To: linux-kernel mailing list; +Cc: pavel

> 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.

We don't need any more bureaucracy.

do_this(a,b);
do_this(a, b);
do_this (a,b);
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.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Coding style: do_this(a,b) vs. do_this(a, b)
  2004-08-17 11:51 Coding style: do_this(a,b) vs. do_this(a, b) Albert Cahalan
@ 2004-08-17 16:07 ` Alexander Nyberg
  2004-08-17 16:40 ` Pavel Machek
  1 sibling, 0 replies; 10+ messages in thread
From: Alexander Nyberg @ 2004-08-17 16:07 UTC (permalink / raw)
  To: Albert Cahalan; +Cc: linux-kernel mailing list, pavel

On Tue, 2004-08-17 at 13:51, Albert Cahalan wrote:
> > 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.
> 
> We don't need any more bureaucracy.
> 
> do_this(a,b);
> do_this(a, b);
> do_this (a,b);
> 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.

Some of us do see it and find it very annoying, I'm one of those who
very much prefer do_this(a, b) and especially when there are 
more than two parameters.

One of the reasons I do like linux is the coding standard, I find many
other projects completely unreadable.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Coding style: do_this(a,b) vs. do_this(a, b)
  2004-08-17 11:51 Coding style: do_this(a,b) vs. do_this(a, b) Albert Cahalan
  2004-08-17 16:07 ` Alexander Nyberg
@ 2004-08-17 16:40 ` Pavel Machek
  2004-08-17 17:07   ` Albert Cahalan
  1 sibling, 1 reply; 10+ messages in thread
From: Pavel Machek @ 2004-08-17 16:40 UTC (permalink / raw)
  To: Albert Cahalan; +Cc: linux-kernel mailing list

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?

> 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.

								Pavel
-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Coding style: do_this(a,b) vs. do_this(a, b)
  2004-08-17 16:40 ` Pavel Machek
@ 2004-08-17 17:07   ` Albert Cahalan
  2004-08-17 20:00     ` Pavel Machek
  0 siblings, 1 reply; 10+ messages in thread
From: Albert Cahalan @ 2004-08-17 17:07 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linux-kernel mailing list

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.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Coding style: do_this(a,b) vs. do_this(a, b)
  2004-08-17 17:07   ` Albert Cahalan
@ 2004-08-17 20:00     ` Pavel Machek
  0 siblings, 0 replies; 10+ messages in thread
From: Pavel Machek @ 2004-08-17 20:00 UTC (permalink / raw)
  To: Albert Cahalan; +Cc: linux-kernel mailing list

Hi!

> > 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.

This kind of spacing matters, too.

> > > 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);

This looks ugly.

> 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"

Would be okay. Notice that I did not add a rule, I just fixed the
examples to be consistent with each other.

Anyway, as in common english, there should be space after ",". There
may be exception to the rule (your baz example), but...

Here's the patch again. macrofun() is used as an example, but it looks
ugly, and is not consistent with the rest of the document.
								Pavel

--- clean/Documentation/CodingStyle	2004-05-20 23:08:01.000000000 +0200
+++ linux/Documentation/CodingStyle	2004-06-06 00:27:11.000000000 +0200
@@ -356,11 +356,11 @@
 
 Macros with multiple statements should be enclosed in a do - while block:
 
-#define macrofun(a,b,c) 			\
+#define macrofun(a, b, c) 			\
 	do {					\
 		if (a == 5)			\
-			do_this(b,c);		\
-	} while (0)
+			do_this(b, c);		\
+	} while(0)
 
 Things to avoid when using macros:
 

-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Coding style: do_this(a,b) vs. do_this(a, b)
  2004-08-17 10:38 Pavel Machek
@ 2004-08-17 21:09 ` Fao, Sean
  2004-08-17 21:14   ` Pavel Machek
  2004-08-17 21:59 ` Frank van Maarseveen
  1 sibling, 1 reply; 10+ messages in thread
From: Fao, Sean @ 2004-08-17 21:09 UTC (permalink / raw)
  To: Pavel Machek; +Cc: kernel list, Andrew Morton

Speaking of style preferences, does anybody else feel that there are too 
many spaces in the indentations?  I personally prefer no more than two 
or three spaces, as I can fit a lot more code per line that way.

-- 
Sean

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Coding style: do_this(a,b) vs. do_this(a, b)
  2004-08-17 21:09 ` Fao, Sean
@ 2004-08-17 21:14   ` Pavel Machek
  0 siblings, 0 replies; 10+ messages in thread
From: Pavel Machek @ 2004-08-17 21:14 UTC (permalink / raw)
  To: Fao, Sean; +Cc: kernel list, Andrew Morton

Hi!

> Speaking of style preferences, does anybody else feel that there are too 
> many spaces in the indentations?  I personally prefer no more than two 
> or three spaces, as I can fit a lot more code per line that way.

Better not start *that* flamewar.

[Its on purpose, see archives.]
								Pavel
-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Coding style: do_this(a,b) vs. do_this(a, b)
  2004-08-17 10:38 Pavel Machek
  2004-08-17 21:09 ` Fao, Sean
@ 2004-08-17 21:59 ` Frank van Maarseveen
  2004-08-17 22:29   ` Andrew Morton
  1 sibling, 1 reply; 10+ messages in thread
From: Frank van Maarseveen @ 2004-08-17 21:59 UTC (permalink / raw)
  To: Pavel Machek; +Cc: kernel list, Andrew Morton

On Tue, Aug 17, 2004 at 12:38:52PM +0200, Pavel Machek wrote:
> Hi!
> 
> -	} while (0)
> +	} while(0)

"while" is not a function so I'd keep the space. Both coding style
and kernel/*.c (had to pick something) seem to agree upon this: put
a space between keyword and expression.

-- 
Frank

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Coding style: do_this(a,b) vs. do_this(a, b)
  2004-08-17 21:59 ` Frank van Maarseveen
@ 2004-08-17 22:29   ` Andrew Morton
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2004-08-17 22:29 UTC (permalink / raw)
  To: Frank van Maarseveen; +Cc: pavel, linux-kernel

Frank van Maarseveen <frankvm@xs4all.nl> wrote:
>
> On Tue, Aug 17, 2004 at 12:38:52PM +0200, Pavel Machek wrote:
> > Hi!
> > 
> > -	} while (0)
> > +	} while(0)
> 
> "while" is not a function so I'd keep the space.

My stealth error corrector already did that ;)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-08-17 22:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-17 11:51 Coding style: do_this(a,b) vs. do_this(a, b) Albert Cahalan
2004-08-17 16:07 ` Alexander Nyberg
2004-08-17 16:40 ` Pavel Machek
2004-08-17 17:07   ` Albert Cahalan
2004-08-17 20:00     ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2004-08-17 10:38 Pavel Machek
2004-08-17 21:09 ` Fao, Sean
2004-08-17 21:14   ` Pavel Machek
2004-08-17 21:59 ` Frank van Maarseveen
2004-08-17 22:29   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox