Re: Coding style question

Поиск
Список
Период
Сортировка
От
Тема Re: Coding style question
Дата
Msg-id 1162497726.7998.310.camel@sakai.localdomain
обсуждение исходный текст
Ответ на Re: Coding style question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
<blockquote type="CITE"><pre>
<font color="#000000"><<a href="mailto:korryd@enterprisedb.com">korryd@enterprisedb.com</a>> writes:</font>
<font color="#000000">> initializers also force you to declare variables in the scope where they</font>
<font color="#000000">> are needed.  Instead of declaring every variable at the start of the</font>
<font color="#000000">> function, it's better to declare them as nested as practical (not as</font>
<font color="#000000">> nested as possible, but as nested as practical).</font>

<font color="#000000">I agree that in many places it'd be better style to declare variables in</font>
<font color="#000000">smaller scopes ... but that's not the point you started the thread with.</font>
<font color="#000000">In any case, the initializer-vs-assignment decision is the same no</font>
<font color="#000000">matter what scope you're talking about --- I don't see how that "forces"</font>
<font color="#000000">you to do it either way.</font>
</pre></blockquote><br /> Right - I should have said that <i>proper</i> initialization encourages you to declare
variablesin nested scopes (<i>proper</i> meaning that the initializer puts a meaningful value into the variable, not
justa default NULL or 0) - if the initializer depends on a computed value, you can't initialize until that value has
beencomputed.  <br /><br /> I guess the two issues are not all that related - you can initialize without nesting (in
manycases) and you can nest without initializing.  They are both readability and maintainability issues to me.<br /><br
/>Thanks for the feedback.  <br /><br />             -- Korry<br /><br /><br /> 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Magnus Hagander"
Дата:
Сообщение: Re: Design Considerations for New Authentication Methods
Следующее
От:
Дата:
Сообщение: Re: Coding style question