Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Feb 2005 18:03:38 +1100
From:      Peter Jeremy <PeterJeremy@optushome.com.au>
To:        Ryan Sommers <ryans@gamersimpact.com>
Cc:        arch@freebsd.org
Subject:   Re: c99/c++ localised variable definition
Message-ID:  <20050201070338.GA45608@cirb503493.alcatel.com.au>
In-Reply-To: <41FE426E.1050807@gamersimpact.com>
References:  <20050128173327.GI61409@myrddin.originative.co.uk> <20050131102630.GJ61409@myrddin.originative.co.uk> <41FE426E.1050807@gamersimpact.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050201070338.GA45608>