From 6471189942312201353
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8117e5706dc0b4bb
X-Google-Attributes: gidf78e5,public
From: maxtal@Physics.usyd.edu.au (John Max Skaller)
Subject: Re: Redundant Using Declarations
Date: 1995/05/28
Message-ID: <D9B6AA.Byy@ucc.su.OZ.AU>#1/1
X-Deja-AN: 103760157
sender: news@ucc.su.OZ.AU
references: <D8xsur.Ew2@ucc.su.OZ.AU> <3pvffk$jo5@offas_dike.sbil.co.uk>
organization: School of Physics, University of Sydney, Australia
newsgroups: comp.std.c++

In article <3pvffk$jo5@offas_dike.sbil.co.uk>,
Marc Shepherd <shepherd@debussy.sbi.com> wrote:
>In article Ew2@ucc.su.OZ.AU, maxtal@Physics.usyd.edu.au (John Max Skaller) writes:
>>In article <3pi75q$ihm@offas_dike.sbil.co.uk>,
>>Marc Shepherd <shepherd@debussy.sbi.com> wrote:
>::Subclause 7.3.3 of the draft WP says:
>::
>::   A using-declaration is a declaration and can therefore be
>::   used repeatedly where (and only where) multiple declarations
>::   are allowed.
>>
>>	No: a definition is also a declaration, and it _cannot_
>>be repeated: it isn't a question of where "multiple declarations"
>>are allowed: multiple definitions in the one scope are never
>>allowed, and multiple declarations which are not definitions
>>always are. (Multiple declarations which are not definitions
>>must obey certain rules about not changing linkage attributes 
>>or type or return type)
>
>I'm not sure what you're saying "no" to.  The passage above was
>quoted directly from the WP.  Are you saying the WP is incorrect?

	It certainly is not making a coherent normative statement.
Such imprecise gobbledegook is not suitable for a Standard.

	As I said, every definition is a declaration. There is
no question of ANY context in which "multiple declarations are
allowed". It may be that multiple declarations of some name are always
allowed in some contexts and that of these declarations at most
one may also be a definition.

>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
>   }

	Right.

>Consider the following:
>
>   void f()
>   {
>      using A::i;
>      using A::i;     // error, according to the example from the WP quoted above
>      extern int j;
>      extern int j;   // my Sun 4.0 compiler accepts this,
>                      // and I find no text in the WP that disallows it
>   }

	Yep -- the WP is wrong in my opinion.
>
>The two using declarations and the two extern declarations above are all
>plain declarations, not definitions.  Yet, the redundant externs seem to
>be well-formed, but the example in the WP says that the two using's are
>not.

	Yes, its wrong.
>
>So, pardon my persistence, but it *still* seems to me that either the
>normative text or the example--one or the other--is wrong.

	I agree. The example is wrong, and the text you quote
is not precise enough to be considered in any way "normative text".

	The rule is simple: if you can write a using declaration,
you can write any number of them including repetitions.

	That is, "using X::f;" means "ensure that a use of 
plain 'f' finds X::f". I use the word "ensure" to suggest
there is no error ensuring something more than once.

	The reason this behaviour is essential -- there is no
other alternative -- is as follows:

	namespace A { int i; }
	namespace B { using A::i; }
	namespace C { using A::i; }

	using namespace A;
	using namespace B;

We do not want an error here -- there is only one "i" in namespace A.
The using directive treat this code "as if"

	namespace A { int i; }
	using A::i; 
	using A::i; 

had been written -- so it had better not be an error.

BTW: I think the WP is getting confused about

	void f() {
		int i;
		int i;
	}

in which case the two declarations _are_ definitions.

--
        JOHN (MAX) SKALLER,         INTERNET:maxtal@suphys.physics.su.oz.au
	Maxtal Pty Ltd,		    
        81A Glebe Point Rd, GLEBE   Mem: SA IT/9/22,SC22/WG21 
        NSW 2037, AUSTRALIA	    Phone: 61-2-566-2189



