Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!decwrl!world!wmm From: wmm@world.std.com (William M Miller) Newsgroups: comp.std.c++ Subject: Re: "module" facility for top-level namespace control Keywords: namespace, module Message-ID: <1991Apr23.030349.5938@world.std.com> Date: 23 Apr 91 03:03:49 GMT References: <1991Apr19.183922.1982@kodak.kodak.com> <5143@lupine.NCD.COM> <1991Apr21.172735.1123@lth.se> Distribution: comp.std.c++ Organization: Glockenspiel, Ltd. Lines: 35 dag@control.lth.se (Dag Bruck) writes: > Another property I like in Modula-2 is to be able to selectively > import names from a module, i.e., > > IMPORT fission FROM Atomic; > > I do not see how this very useful feature could be provided with the > class-as-module-and-no-new-keywords-please approach. This is something I "discovered" recently when Ron Guilmette brought up this question a while back: You can selectively import types and static members (data and functions) from a class into a scope using typedefs and references. For instance: class X { public: class Y { ... }; static void f(); static int i; }; typedef X::Y Y; void (&f)() = X::f; int& i = X::i; void g() { Y y; // X::Y f(); // X::f() i = 5; // X::i } It's not as simple as IMPORT x FROM y, but it does the trick. -- William M. Miller, Glockenspiel, Ltd. wmm@world.std.com