Declaration within a loop.

Dave Jones djones at megatest.UUCP
Thu Sep 28 08:49:38 AEST 1989


>From article <27519 at amdcad.AMD.COM>, by tim at cayman.amd.com (Tim Olson):
...
> 
> But sometimes it is better to declare the variable in the block to
> limit its scope rather than to make every variable visible to the
> entire function.


Why did you not say, "Always it is better to declare..."?

The only reason I can think of not to put variables into the most
restrictive scope that will contain them is that dbx has a bug that
causes it to give wrong results without complaint or warning if you use
the same name in two scopes.

There's nothing more sickening than to be confronted by an enemy procedure
with a skillion variables declared at the top.  Usually they have
generic names like, "temp1", and "ptr".

Well okay, maybe there's one thing more sickening than that, but I don't
see any reason to bring Jerry Lewis into this.



More information about the Comp.lang.c mailing list