public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Angelo Dell'Aera" <buffer@antifork.org>
To: Valdis.Kletnieks@vt.edu
Cc: Linux-Kernel <linux-kernel@vger.kernel.org>,
	Giuliano Pochini <pochini@shiny.it>,
	Michael Frank <mhf@linuxmail.org>
Subject: Re: PATCH, RFC: 2.6 Documentation/Codingstyle
Date: Fri, 13 Feb 2004 17:38:15 +0100	[thread overview]
Message-ID: <20040213173815.256d5bac.buffer@antifork.org> (raw)
In-Reply-To: <200402131548.i1DFmECc020354@turing-police.cc.vt.edu>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 13 Feb 2004 10:48:14 -0500
Valdis.Kletnieks@vt.edu wrote:

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

I'm not saying "just inline anything and you'll solve problems". I'm saying
that if your design is well done and you consider the availability of the
inlines your code will surely be better. And maybe you wouldn't need to discuss
why the current limit is 80...

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

I prefer going flipping back and forth rather than reading an uncomprehensible 
source. Simpler functions may be analyzed and debugged in a faster way. If
you dislike going back and forth by hand some tools could help you (think 
about cscope). Taking a look at the kernel code it's easy to realize I'm not 
the only one thinking so...

Moreover, if you take a look at the kernel code you'll realize that well 
written code usually defines inlines you really shouldn't need to read since 
their names are quite often self-explaining. Taken from CodingStyle "If you 
have a function that counts the number of active users, you should call that 
"count_active_users()" or similar, you should _not_ call  it "cntusr()"." 

Please don't think simply at those who are reading the code. Think about the 
persons which wrote that code which want to remember what they did two weeks 
before...

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

You could create a lot of examples where it's difficult to create an
inline.. but they're just examples! There are a lot of ways for writing
the same code and maybe if your example was taken from a real-life code
it could be written in a different and more easy-to-read manner. 

Regards.

- --

Angelo Dell'Aera 'buffer' 
Antifork Research, Inc.	  	http://buffer.antifork.org

PGP information in e-mail header


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFALP13pONIzxnBXKIRAsddAJ0UkI8RkgyVsCe9CEgCAq3OjT3X6wCfZFOE
b7fPjRZw+/Dfv05H+aO6tpw=
=KXgO
-----END PGP SIGNATURE-----

  reply	other threads:[~2004-02-13 16:38 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-12 22:15 PATCH, RFC: 2.6 Documentation/Codingstyle Michael Frank
2004-02-12 23:20 ` Tim Bird
2004-02-12 23:46   ` Måns Rullgård
2004-02-13  0:19   ` Tim Hockin
2004-02-12 23:38 ` Randy.Dunlap
2004-02-13  1:50   ` Alex Goddard
2004-02-13  1:52   ` Maciej Zenczykowski
2004-02-13  0:13 ` viro
2004-02-13  1:12 ` J. Bruce Fields
2004-02-13  8:49 ` PATCH, RFC: Version 2 of 2.6 Codingstyle Michael Frank
2004-02-13  9:44   ` Andries Brouwer
2004-02-13 11:24     ` Nikita Danilov
2004-02-16 17:56     ` Ludootje
2004-02-13 22:38   ` Randy.Dunlap
2004-02-13  8:58 ` PATCH, RFC: 2.6 Documentation/Codingstyle Giuliano Pochini
2004-02-13  9:10   ` Andrew Morton
2004-02-13  9:49     ` Michael Frank
2004-02-13 10:09       ` Nick Piggin
2004-02-13 10:50         ` Michael Frank
2004-02-18  7:39           ` Miles Bader
2004-02-13 12:44     ` viro
2004-02-13  9:19   ` David Weinehall
2004-02-13 11:42   ` Andries Brouwer
2004-02-13 12:13     ` Måns Rullgård
2004-02-13 12:42     ` Ed Tomlinson
2004-02-13 13:55     ` Giuliano Pochini
2004-02-13 14:35       ` Angelo Dell'Aera
2004-02-13 15:42         ` Giuliano Pochini
2004-02-13 15:48         ` Valdis.Kletnieks
2004-02-13 16:38           ` Angelo Dell'Aera [this message]
2004-02-13 17:03             ` Valdis.Kletnieks
2004-02-13 16:18       ` viro
2004-02-14  0:38 ` Kevin O'Connor
2004-02-14  0:56   ` Valdis.Kletnieks
2004-02-14  1:44 ` PATCH, RFC: Version 3 of 2.6 Codingstyle Michael Frank
2004-02-14  3:44   ` Dmitry Torokhov
2004-02-15 10:09     ` Jamie Lokier
2004-02-14 20:44 ` PATCH, RFC: Version 4 " Michael Frank
2004-02-14 21:27   ` viro
2004-02-16  3:47 ` PATCH, RFC: Version 5 " Michael Frank
     [not found] <fa.fbh88ra.kn8094@ifi.uio.no>
2004-02-13  6:41 ` PATCH, RFC: 2.6 Documentation/Codingstyle Junio C Hamano
2004-02-13  7:18   ` vda
2004-02-13 12:37     ` Maciej Zenczykowski
2004-02-13 13:57       ` vda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040213173815.256d5bac.buffer@antifork.org \
    --to=buffer@antifork.org \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhf@linuxmail.org \
    --cc=pochini@shiny.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox