From -7652994667188048599
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,8117e5706dc0b4bb
X-Google-Attributes: gidf78e5,public
From: schuenem@informatik.tu-muenchen.de (Ulf Schuenemann)
Subject: Re: Redundant Using Declarations
Date: 1995/05/31
Message-ID: <3qhus6$7pl@hpsystem1.informatik.tu-muenchen.de>#1/1
X-Deja-AN: 103643999
distribution: world
references: <D8xsur.Ew2@ucc.su.OZ.AU> <3pvffk$jo5@offas_dike.sbil.co.uk>
organization: Technische Universitaet Muenchen, Germany
newsgroups: comp.std.c++
originator: schuenem@hpbroy3.informatik.tu-muenchen.de


In article <3pvffk$jo5@offas_dike.sbil.co.uk>, shepherd@debussy.sbi.com (Marc Shepherd) writes:
[..]
|> I think we can agree that the following is well-formed:
|> 
|>    namespace A2 {
|>       using A::i;
|>       using A::i;     // ok: double declaration
|>       extern int j;
|>       extern int j;   // ok: double declaration
|>    }

I'm afraid by the current wording of the standard it's not what you intend:
7.3.1.4 Namespace member definitions [namespace.memdef] 4 says:
> When an entity declared with the extern specifier is not found to refer
> to some other declarartion, then that entity is a member of the innermost
> enclosing namespace.

I can't see anything there that prevents me from concluding that you
are declaring ::j and not A2::j.
I find this situation very very unpleasent.

   HOW CAN I _DECLARE_ A NAMESPACE-MEMBERVARIABLE ???

It would be a shame, if namespaces where mainly designed for functions
(that need no extern) but not also for objects.

7.3.1.4 gives an example with extern within the body of a namespace-
memberfunction. The analogon for a namespace-membernamespace:

namespace X {
	namespace p {
		extern int	q;	// a is a member of namespace X ???
		int	f ()
		{	return q; }	// referes to X::q ???
	}
	int	middle ()
	{	return p::q; }		// error: q not yet declared ???

	int	p::q = 2;		// error: q is not a member of p ???
}

IMHO the wording should be changed at least to something like:
> Within a scope that is not a namespace, when an entity declared with
> the extern specifier ...

NOTE: As I understand 7.3.1.4 this is not a clarification but a change !


Ulf Schuenemann

--------------------------------------------------------------------
Ulf Sch�nemann
Fakult�t f�r Informatik, Technische Universit�t M�nchen, Germany.
email: schuenem@informatik.tu-muenchen.de




