🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1034

Re: "module" facility for top-level namespace control

#1034
From: William M Miller
Date: Tue, 23 Apr 1991 03:03
35 lines
1591 bytes
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
Technical Details
Message-ID: <1991Apr23.030349.5938@world.std.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!decwrl!world!wmm
References: <1991Apr19.183922.1982@kodak.kodak.com> <5143@lupine.NCD.COM> <1991Apr21.172735.1123@lth.se>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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