Re: Question about style when converting from K&R to ANSI C.

Willy Tarreau (willy@w.ods.org)
Sun, 1 Jun 2003 16:22:37 +0200


On Sun, Jun 01, 2003 at 07:06:02AM -0700, Larry McVoy wrote:

> It may be just what you are used to but I also find that when reading lots
> of code it is nice to have it look like

Well, I think it's the _main_ reason for most of us coding this way. When
you're used to read it this way, it seems completely normal, and other methods
seem strange. I even used to put the opening brace on the same line as the
function, because I don't like having a line with a single char, I find it a
wast of screen space. But the kernel coding style slowly makes me move forward
to its method.

> return type
> function_name(args)
>
> because the function_name() stands out more, it's always at the left side so
> I tend to parse it a little more quickly.

I can agree with you on this point. It's only that since I'm not used to read
it this way, I have to make an effort finding the type, even if it's just above.
I will try to use this method just to see if I can feel comfortable with it.

> Don't get me wrong, I'm not arguing that you should go reformat all your
> code (I tend to agree with Linus, if it's not your code, don't stick your
> fingers in there just because you want to reformat it). All I'm doing
> is trying to understand why in this instance did Linux diverage from
> common practice.

I just found through google that C programs are indeed formated as you say,
but C++ programs have the type on the same line as the name. So if this
comes from this origin, we'll be able to say that Linux contains no C++ except
its formating :-)

Cheers,
Willy

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