While it was 2/10/04 7:33 PM throughout the UK, Joe sprinkled little
black dots on a white screen, and they fell thus:
Is it generally considered "better" (i.e. clearer) to declare all variables
at the start of a function or as you need them within it?
I personally tend to put them at the beginning for the most part - this
means that they're not going to get lost as they're scattered about my
function bodies.
But if I'm defining a function that can be logically divided into
phases, then if a phase introduces new variables I'd tend to declare
them at the beginning of the phase.
Of course, if you've got object initialisations depending on values
calculated within the function, that's another matter....
Stewart.
--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.