Article View: comp.std.c++
Article #1025"module" facility for top-level namespace control
From: Scott Layson Burson
Date: Fri, 19 Apr 1991 16:32
Date: Fri, 19 Apr 1991 16:32
53 lines
2562 bytes
2562 bytes
I seem to recall a recent posting or two discussing the possibility of
controlling the top-level namespace of a C++ program through some sort
of module facility. Or rather, one person said they thought some such
proposal had been made, and there was a response by someone else who
was not aware of any such proposal. Or something like that. (I
didn't see the messages when I quickly scanned back.) Anyhow --
To see if we can get some discussion going on the matter, let me
sketch a simple proposal. Suppose we were to introduce a keyword
"module" with a simple syntax:
module Foo {
// ... declarations
}
The intent here is that the declarations within the braces have
exactly the same form as those normally found at top level, so that
one can write things like
module Foo {
#include "something.h"
}
where the author of the header file need not have done anything
special to make such usage possible.
The meaning would be simply to put the code within the braces into
namespace Foo, as if Foo were a class; outside the construct,
referencing names defined inside it would require prepending `Foo::'.
Multiple module constructs with the same name would refer to the same
module, so that one could have a header file that looked like the
previous example and also, separately, a .cc file containing:
module Foo {
#include "something.cc"
}
and the two pieces would connect up in the obvious way.
Seems like this would make the world safe for all those of us who want
to name one of our classes "Object".
The only problem I can see with it concerns the issue of binary-only
library distribution, which, it has already been noted, is problematic
anyway. It is not hard to imagine linker extensions that could fix
this, but I gather that is considered an undesirable thing to do.
It seems to me that C++ needs something along these lines fairly
badly. Certainly this strikes me as a far better sort of solution
than any kind of central registry of names. Comments?
-- Scott
Gyro@Reasoning.COM
Technical Details
Message-ID:
<1991Apr19.163253.22253@kestrel.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!uwm.edu!bionet!ucselx!petunia!kestrel.edu!gyroShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!uwm.edu!bionet!ucselx!petunia!kestrel.edu!gyro From: gyro@kestrel.edu (Scott Layson Burson) Newsgroups: comp.std.c++ Subject: "module" facility for top-level namespace control Keywords: namespace, module Message-ID: <1991Apr19.163253.22253@kestrel.edu> Date: 19 Apr 91 16:32:53 GMT Distribution: comp.std.c++ Organization: Kestrel Institute, Palo Alto, CA Lines: 53