Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!bfmny0!tneff
From: tneff@bfmny0.UU.NET (Tom Neff)
Newsgroups: comp.lang.c
Subject: Re: Declaration within a loop.
Message-ID: <14743@bfmny0.UU.NET>
Date: 27 Sep 89 16:18:09 GMT
References: <2085@hydra.gatech.EDU> <30174@news.Think.COM> <559@crdos1.crd.ge.COM>
Reply-To: tneff@bfmny0.UU.NET (Tom Neff)
Distribution: usa
Lines: 22
Summary:
Expires:
Sender:
Followup-To:

In article <559@crdos1.crd.ge.COM> davidsen@crdos1.UUCP (bill davidsen) writes:
>  Most C compilers allocate space on the stack for this when the
>procedure is entered.  It therefore is not a practical thing to do to
>save space. 

For what it's worth AT&T's pcc on V/386 does share reuse stack space
among all temp in-block variables.  Intel's C compiler does not though.
I'm sure there are tons of other examples pro and con.

>             The most common use is to correct for having forgotten to
>declare a variable at the start of a procedure.

Here I must disagree.  The most common and obvious use of an in-block
temp is to restrict scope!  Unless one's editor lacks a "move up"
command there is no reason to declare a variable locally within a block
just because one "forgot" to declare it function-wide!  The declaration
is as easily added in one place as the other.  But it may be quite
important to ensure that "i" or "swaptmp" is unheard-of outside the
local block.
-- 
Annex Canada now!  Free Quebec; raze and depopulate  |  Tom Neff
Ontario; license Inuit-run casinos on the BC shore.  |  tneff@bfmny0.UU.NET