[PATCH] move many decls "down" to where used; no semantic change

Jeff Darcy jdarcy at redhat.com
Mon Mar 14 15:52:01 UTC 2011


On 03/14/2011 03:10 AM, Jim Meyering wrote:
> Pete Zaitcev wrote:
>> On Fri, 11 Mar 2011 21:45:04 +0100
>> Jim Meyering <jim at meyering.net> wrote:
>>
>>> Changes like these make the code marginally easier to read and to maintain.
>>
>> This is nasty, C++ish style, but whatever.
> 
> Hi Pete,
> 
> That is a feature of C99: declarations after statements.
> It's been available in gcc for almost 20 years.
> Do you have an argument against the style other than
> "that's not the way <some group> does it"?

Where's the empirical argument *for* that style, from those proposing
the change and making claims for its efficacy?  If declarations can
occur anywhere, they can require more work to find - either by a human,
or by a tags/IDE program which has to disambiguate appearances of the
same symbol.  If declarations are concentrated at the top of functions,
then they are extremely easy to find without having to examine multiple
scopes.  This approach also avoids many issues of aliasing/shadowing,
etc.  Overall, I'd say that declarations following statements are bad
for readability/maintainability, and would be surprised to find any
serious analysis concluding otherwise.


More information about the iwhd-devel mailing list