lkml.org 
[lkml]   [2000]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] removal of "static foo = 0"
On Sat, Nov 25, 2000 at 06:02:51PM -0500, Jeff Garzik wrote:
> Andries Brouwer wrote:
> > In a program source there is information for the compiler
> > and information for the future me. Removing the " = 0"
> > is like removing comments. For the compiler the information
> > remains the same. For the programmer something is lost.
>
> This is pretty much personal opinion :)
>
> The C language is full of implicit as well as explicit features. You
> are arguing that using an implicit feature robs the programmer of
> information. For you maybe... For others, no information is lost AND
> the code is more clean AND the kernel is smaller. It's just a matter of
> knowing and internalizing "the rules" in your head.

Oh Jeff,

All these really good people, unable to capture a simple idea.
Let me try one more time.
There is information. The information is:
"this variable needs initialization"
Now you tell me to know simple rules. OK, I know them.
But what do they tell me about my variables a and b, where
a requires initialization and b does not require it?

One can write a comment, like

int a; /* this variable needs initialization, fortunately
it is already initialized at startup */
int b; /* no initialization required */

But that is overdoing it, it uglifies the code.
One can leave the comment out, like

int a, b;

But then next month, when you decide to move this into
some function

int foo() {
int a, b;
...

there is no indication that you need an additional

a = 0;

You see?
There is real information here. Useful as a reminder.
Not necessary. The perfect programmer would see
immediately that the assignment is required, also
without the reminder. But not everybody is perfect
all of the time, and sometimes the code involved is
quite complicated. The tiny convention
"write an explicit initialization when initialization is needed"
is helpful. It is a form of program documentation.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:47    [W:0.094 / U:0.184 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site