Re: Coding style question

Поиск
Список
Период
Сортировка
От
Тема Re: Coding style question
Дата
Msg-id 1162495398.7998.298.camel@sakai.localdomain
обсуждение исходный текст
Ответ на Re: Coding style question  (Neil Conway <neilc@samurai.com>)
Ответы Re: Coding style question  (Neil Conway <neilc@samurai.com>)
Список 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 по дате отправления:

Предыдущее
От:
Дата:
Сообщение: Re: Coding style question
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Coding style question