public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luben Tuikov <luben@splentec.com>
To: root@chaos.analogic.com
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] coding style addendum
Date: Mon, 10 Mar 2003 16:53:46 -0500	[thread overview]
Message-ID: <3E6D096A.1080006@splentec.com> (raw)
In-Reply-To: Pine.LNX.3.95.1030310162308.14367A-100000@chaos

Richard B. Johnson wrote:
> On Mon, 10 Mar 2003, Luben Tuikov wrote:
> 
> 
>>Someone may find this helpful and descriptive of how kernel code
>>should be developed.
> 
> [SNIPPED...]
> 
> 
>>+      Make sure every module/subroutine hides something.
> 
> 
> This is not correct. Well known example:
> 
> #include <math.h>
> 
> double hypot(double x, double y) {
>     return sqrt((x * x) + (y * y));
> }
> 
> This subroutine hides nothing. It receives input parameters

It does hide something.  It hides *the implementation* of
the function hypot().

In effect, elsewhere in your code you could have the explicit
	... = sqrt((x * x) + (y * y));
or,
	... = hypot(x, y);

It's just eliminating (code) redundancy and duplication.

I.e. this addendum was meant on a more abstract/logical ground, thus the
name of the chapter.

[cut]
> locally stored and therefore not hidden. Your rule would require
> the replication of three floating-point variables NotGood(tm).

This isn't really my rule.  I didn't invent or came up with anything
new here.

Documentation/CodingStyle is remarkably similar to most of what
you'd find in [1], and those rules are more or less from that
same book.

Actually, the whole point of my posting the patch is the last rule,
since well thought out data representation makes or breaks the code.

References:
[1] ``The Elements of Programming Style'' by Kernighan
and Plauger, 2nd ed, 1988, McGraw-Hill.

-- 
Luben



  reply	other threads:[~2003-03-10 21:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-10 20:56 [PATCH] coding style addendum Luben Tuikov
2003-03-10 21:32 ` Richard B. Johnson
2003-03-10 21:53   ` Luben Tuikov [this message]
2003-03-10 22:07     ` Tommy Reynolds
2003-03-10 22:30       ` Luben Tuikov

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=3E6D096A.1080006@splentec.com \
    --to=luben@splentec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=root@chaos.analogic.com \
    /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