Re: Coding style question - Mailing list pgsql-hackers

From
Subject Re: Coding style question
Date
Msg-id 1162495398.7998.298.camel@sakai.localdomain
Whole thread Raw
In response to Re: Coding style question  (Neil Conway <neilc@samurai.com>)
Responses Re: Coding style question  (Neil Conway <neilc@samurai.com>)
List pgsql-hackers
<blockquote type="CITE"><pre>
<font color="#000000">> Shouldn't we turn on warnings by the compiler on uninitialized</font>
<font color="#000000">> variables? This can also be helpful.</font>

<font color="#000000">Those warnings should already be enabled, at least with GCC.</font>
</pre></blockquote><br /> Yes, the compiler can detect unitialized variables,  <br /><br /> But, that introduces a new
problem. There are a lot of tools out there (like GCC) that can find unitialized variables (or more specifically,
variableswhich are used before initialization).  I've seen too many less-scarred developers add an " = NULL" to quiet
downthe tool.  But that's (arguably) worse than leaving the variable uninitialized - if you simply initialize a
variableto a known (but not correct) value, you've disabled the tool; it can't help you find improperly initialized
variablesanymore.  The variable has a value, but you still don't know at which point in time it has a <i>correct</i>
value.<br/><br /> That's another reason I prefer initializers (and nested variable declarations) - I can put off
creatingthe variable until I can assign a meaningful value to it.   (I don't go so far as to introduce
<i>artificial</i>scopes just for the sake of nesting variable declarations).<br /><br /> Too many scars...<br /><br />
           -- Korry<br /><br /> 

pgsql-hackers by date:

Previous
From:
Date:
Subject: Re: Coding style question
Next
From: Tom Lane
Date:
Subject: Re: Coding style question