c99/c++ localised variable definition
Peter Jeremy
PeterJeremy at optushome.com.au
Mon Jan 31 23:04:46 PST 2005
On Mon, 2005-Jan-31 08:36:30 -0600, Ryan Sommers wrote:
>all it takes to force yourself to think "do I really need this?" Or you
>might look at your other declarations and realize, "hey I could use this
>instead."
Finding a stray int (or whatever) that doesn't appear to be live at a
particular point and re-using it for something unrelated isn't
necessarily good coding practice either. This can confuse someone who
is quickly scanning the code - especially if the variable name was
mnemonic and the re-use doesn't match it's name.
It's unfortunate that C doesn't have any way to define the end of a
variable's scope (or lifetime) apart from blocks.
--
Peter Jeremy
More information about the freebsd-arch
mailing list