Re: PATCH, RFC: 2.6 Documentation/Codingstyle

From: Valdis . Kletnieks
Date: Fri Feb 13 2004 - 10:50:13 EST


On Fri, 13 Feb 2004 15:35:42 +0100, "Angelo Dell'Aera" said:

> I think you're really wrong since "deeply nested" means exactly "unreadable
> and badly structured" and you could easily realize it by simply spending ~10
> hours per day coding and/or taking a look at the code written by someone
> which is not you. A simple use of inline functions and a previous thinking
> about what you're going to write could easily solve all problems.

It might help, but a blind belief that "if I inline things it will all be
better" won't solve all the problems. In particular, for the example you
replied to:

>>1 tab in the function, 1tab a switch, 1 if, 1 for, 1 if and you have already
>>lost half of the available space.

you may very well be advocating the inlining of a 3 or 4 line code segment,
and moving it to someplace far away in the .c file. Certainly the compiler
can probably manage to generate the same code, but now you're condemning
the next person who reads this code to go flipping back and forth through
the file to find the only-used-once and unfamiliar function to see what
this for(;;) loop does.

Oh, and it gets very ugly if you have this:

switch
if (foo) {
for (ptr=first; ptr->next!=NULL; prt->next) {
if (!(ptr->somedata))
goto have_to_drop_dead_now;
/* more code that deals with ptr-> here */

Creating an inline function for that is going to be.. interesting. :)


Attachment: pgp00000.pgp
Description: PGP signature