Xref: utzoo comp.lang.c:11977 comp.sys.ibm.pc:18261
Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!mailrus!iuvax!bobmon
From: bobmon@iuvax.cs.indiana.edu (RAMontante)
Newsgroups: comp.lang.c,comp.sys.ibm.pc
Subject: Function declarations (was: MSC v5.1 Bug???)
Message-ID: <11879@iuvax.cs.indiana.edu>
Date: 20 Aug 88 16:31:58 GMT
References: <10102@genrad.UUCP>
Reply-To: bobmon@iuvax.UUCP (RAMontante)
Organization: malkaryotic
Lines: 24

Craig Dawson asks about a program in which two routines try to call a
third, somewhat as follows:

x() { static z(); z(); }
y() { static z(); z(); }

static z() { ; }

(MSC apparently chokes; BTW, TurboC accepts it.)  My question is... Why
declare z() inside the functions x() and y()?  It doesn't make sense
that the name "z" should be localized to these code blocks, since it
has to be global to the entire file (at least) anyway.  Nor do I see
the value of making it a static name, since it references an object
that can't go away or be "reclaimed" outside of x() or y(), namely a
function.  Craig's "fix", declaring static z() prior to and outside of
both x() and y() (an almost-protoype kind of declaration), seems like
the only natural thing to do.

Note:  I understand why local variables are good.  But it seems pointless
to treat the function name as "local", since it must refer to a nonlocal
object.  What am I missing?  Is there a relevant section of K&R I should
read?
-- 
--    bob,mon			(bobmon@iuvax.cs.indiana.edu)
--    "Aristotle was not Belgian..."	- Wanda