The compelling reason for putting variables in the smallest scope possible is that it greatly reduces the likely hood of "action at a distance" style errors that are the bane of using global variables.
Another reason is that good coding style dictates that you declare the variable the first time it is used and initialize it at the same time. It's good coding style because it makes it clear where the variable is first used and how it gets its initial value.
True laziness is hard work
|