public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* namespaces -- time to do something?
@ 1997-12-09  8:17 Marc W. Mengel
  1997-12-09  8:25 ` Jeffrey A Law
  0 siblings, 1 reply; 6+ messages in thread
From: Marc W. Mengel @ 1997-12-09  8:17 UTC (permalink / raw)
  To: egcs

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.

Premise:
--------
Unless I am missing something, it looks like egcs *declares* namespaces 
okay, creates symbols in namespaces properly, and does fully-qualified names 
correctly, it just doesn't do "using" correctly.   

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

similar to TYPENAME, which carry around a tree-node for 
"namespace::name" instead of a type.  We then expand the symbol
to the fully qualified name when needed, like:

qualified_id : NAMESPACE_ID_ALIAS
	{ $$ = EXPAND_NAMESPACE_ALIAS($1); }

qualified_type : NAMESPACE_TYPE_ALIAS
	{ $$ = EXPAND_NAMESPACE_ALIAS($1); }

identifier : NAMESPACE_NAMESPACE_ALIAS
	{ $$ = EXPAND_NAMESPACE_ALIAS($1); }

Then "using" statements simply define the appropriate NAMESPACE_xxx_ALIAS
symbols in the current scope, similiar to how typedefs define a TYPENAME.
(By the way, how *do* typedefs define a TYPENAME?  I've tried to follow
through the code by hand to figure this out and keep getting lost...)

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

This has one possibly confusing side-effect; if we have:

namespace fred {
	int a;
};

namespace jane {
	int b;
	using fred::a;
};

namespace paul {
	int c;
	using jane::a;
}

this could well succeed in making the "a" seen in namespace paul be actually 
fred::a, or fail, depending on how we define EXPAND_NAMESPACE_ALIAS()...
It's not clear to me which way this is supposed to work.

Marc

^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <199712091617.KAA27851.cygnus.egcs@fsui02.fnal.gov>]

end of thread, other threads:[~1997-12-10 19:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-09  8:17 namespaces -- time to do something? Marc W. Mengel
1997-12-09  8:25 ` Jeffrey A Law
     [not found] <199712091617.KAA27851.cygnus.egcs@fsui02.fnal.gov>
1997-12-09 18:44 ` Jason Merrill
1997-12-09 19:34   ` Olivier Galibert
1997-12-10 19:28     ` Per Bothner
     [not found]     ` <199712110309.TAA00961.cygnus.egcs@cygnus.com>
1997-12-10 19:56       ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).