On Sat, 2009-11-14 at 12:49 -0700, David Brownell wrote:
> For the record, I still prefer to see declarations grouped
> at the beginning of their block, after a left bracket.
> That way they're always easy to find.

Rather than where they are first used, where you actually need the
information to understand the code?  I guess it's a matter of where you
expect to start your search algorithm.  For me, it always seems to be at
the point of first use.

But as Øyvind pointed out, this also has the positive effect of reducing
the scope for these variables, meaning the developer has a smaller
working set of variables to consider.  It also serves to partition the
routine into phases, with each in-line block of variables declaring a
new "statement group" of sorts.  A good compiler might even produce
better code, without even throwing optimization into the discussion.
It would be interesting to know for sure.

Regardless, this approach does help when refactoring, because these
statement groups can be copy and pasted cleanly as a block of lines.
After rearranging functions in this manner (doing the compiler's job),
new opportunities for factoring subroutines often become apparent, and
you make it easier to realize them in subsequent patches.

--Z
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to