🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #548

Blocks, scopes and declaration statements

#548
From: Shankar Unni
Date: Mon, 15 Oct 1990 19:19
34 lines
1584 bytes
Does a declaration in the middle of a { } block start a new scope? A new
block?

Consider the following example:

   void foo()
   {
       extern void bar();	// decl
       int i;			// decl
       
       i = 1;			// statement

       extern void bar(int);	// decl: overloaded with above bar()?
       
       bar();			// statement: legal?
   }

Is the second declaration of bar ("extern void bar(int)") considered an
overloaded variant of the parameterless bar(), or the start of a new scope
(so that it hides the parameterless bar())?

Cfront 2.1 (and 2.0) apparently seems to make the latter interpretation,
and complains about the parameterless call to bar().

The ARM (sections 7, 10.4, etc) is suitably obscure on this point. They do
mention that declarations hide other declarations of the same identifier in
"an outer block", but it's unclear as to how that is to be applied in the
above situation.

Anyone care to comment?
-----
Shankar Unni                                   E-Mail: 
Hewlett-Packard California Language Lab.     Internet: shankar@hpda.hp.com
Phone : (408) 447-5797                           UUCP: ...!hplabs!hpda!shankar
Technical Details
Message-ID: <77210008@hpclscu.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpda!hpcuhb!hpcllla!hpclisp!hpclscu!shankar

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpda!hpcuhb!hpcllla!hpclisp!hpclscu!shankar
From: shankar@hpclscu.HP.COM (Shankar Unni)
Newsgroups: comp.std.c++
Subject: Blocks, scopes and declaration statements
Message-ID: <77210008@hpclscu.HP.COM>
Date: 15 Oct 90 19:19:36 GMT
Organization: Hewlett-Packard Calif. Language Lab
Lines: 34