This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: namespaces -- time to do something?
- To: "Marc W. Mengel" <mengel at fnal dot gov>, egcs at cygnus dot com
- Subject: Re: namespaces -- time to do something?
- From: Jason Merrill <jason at cygnus dot com>
- Date: 09 Dec 1997 18:44:01 -0800
- References: <199712091617.KAA27851.cygnus.egcs@fsui02.fnal.gov>
- Reply-To: egcs at cygnus dot com
>>>>> Marc W Mengel <mengel@fnal.gov> writes:
> Well, now that egcs-1.0 is out, it seems to me it's time to do something
> about namespaces for egcs-1.1. Towards that end, I have a simple idea
> that I think will work which I'd like to toss out for folks to knock
> around.
I've already sent out my design for a rewrite of the lookup code, which is
already ill-suited to C++. I'll see about digging it up again.
> Proposal:
> ---------
> If so, I propose we fix this by adding the following tokens to the grammar:
> %token NAMESPACE_ID_ALIAS
> %token NAMESPACE_TYPE_ALIAS
> %token NAMESPACE_NAMESPACE_ALIAS
This seems unnecessary. A using-declaration can be found using the same
lookup as any other declaration, and should use the same tokens.
> The only slightly painful part is when we see a "using xxx;" statement to
> import a whole namespace, we have to make aliases for the whole list of
> symbols in the namespace...
No. That's not how using-directives work. In particular, names added to
the used namespace after the using-directive are also visible. Also, the
lookup in the used namespace happens at the least common denominator of the
current scope and the used namespace. Using-declarations are easy;
using-directives are the hard part.
Jason