Re: Coding style question

Поиск
Список
Период
Сортировка
Искать
От
Тема
Re: Coding style question
Дата
Msg-id
1162497726.7998.310.camel@sakai.localdomain
Ответ на
Список
Дерево обсуждения
Coding style question <korryd@enterprisedb.com>
Re: Coding style question imad <immaad@gmail.com>
Re: Coding style question Neil Conway <neilc@samurai.com>
Re: Coding style question <korryd@enterprisedb.com>
Re: Coding style question Neil Conway <neilc@samurai.com>
Re: Coding style question <korryd@enterprisedb.com>
Re: Coding style question Nolan Cafferky <Nolan.Cafferky@qualitysmith.com>
Re: Coding style question Andrew Dunstan <andrew@dunslane.net>
Re: Coding style question Gregory Stark <stark@enterprisedb.com>
Re: Coding style question <korryd@enterprisedb.com>
Re: Coding style question Tom Lane <tgl@sss.pgh.pa.us>
Re: Coding style question <korryd@enterprisedb.com>
Re: Coding style question Tom Lane <tgl@sss.pgh.pa.us>
Re: Coding style question <korryd@enterprisedb.com>
Re: Coding style question imad <immaad@gmail.com>
Re: Coding style question Tom Lane <tgl@sss.pgh.pa.us>
Re: Coding style question imad <immaad@gmail.com>
Re: Coding style question Andrew Dunstan <andrew@dunslane.net>
<korryd@enterprisedb.com> writes:
> initializers also force you to declare variables in the scope where they
> are needed.  Instead of declaring every variable at the start of the
> function, it's better to declare them as nested as practical (not as
> nested as possible, but as nested as practical).

I agree that in many places it'd be better style to declare variables in
smaller scopes ... but that's not the point you started the thread with.
In any case, the initializer-vs-assignment decision is the same no
matter what scope you're talking about --- I don't see how that "forces"
you to do it either way.

Right - I should have said that proper initialization encourages you to declare variables in nested scopes (proper meaning that the initializer puts a meaningful value into the variable, not just a default NULL or 0) - if the initializer depends on a computed value, you can't initialize until that value has been computed. 

I guess the two issues are not all that related - you can initialize without nesting (in many cases) and you can nest without initializing.  They are both readability and maintainability issues to me.

Thanks for the feedback. 

            -- Korry


В списке pgsql-hackers по дате отправления
От: Magnus Hagander
Дата:
От:
Дата:
Сообщение: Re: Coding style question
FAQ