IDL 4.3 RTF Avatar
  1. OMG Issue

IDL43 — Need the concept of a "using namespace" directive to simplify IDL files

  • Key: IDL43-34
  • Status: open  
  • Source: Real-Time Innovations ( Dr. Gerardo Pardo-Castellote, Ph.D.)
  • Summary:

    Programming languages that have the concept of modules/namespaces also include the concept of "using" a namespace type such that one can ommit the explicit reference to the 'used' namespace.

    The following is an example for C++:

    Assume the declaration:

    namespace MyNamespace
    {
        class MyClass
        {
        public:
            void my_operation() {}
        };
        void MyFunction1(MyClass) {}
    }
    

    Normally these types need to be accessed using their fully qualified names:

    MyNamespace::MyClass obj;
    obj.my_operation();
    MyNamespace::MyFunction1(obj);
    

    This can be cumbersome when having to reference a lot of types in the same namespace, specially for deep nested namespaces.

    The C++ using declaration can bring the name space or individual types into scope simplifying the coding as in:

    using MyNamespace::MyClass;
    MyClass obj;
    obj.my_operation();
    MyFunction1(obj);
    

    Or alternatively bringing every type in the name space into the scope:

    using namespace MyNamespace;
    MyClass obj;
    obj.my_operation();
    MyFunction1(obj);
    

    Java and C# provide similar facilities:
    In Java the "import" keyword is used to import packages or types into the scope. The syntax is:

    import package.name.ClassName;   // To import a certain class only
    import package.name.*;
    

    In C# the "using" keyword is used to import namespaces or types into the scope. The syntax is:

    using  MyNamespaceName.MyClassName;   // To import a certain class only
    using MyNamespaceName;
    

    This issue request that a similar facility is added to IDL

  • Reported: IDL 4.2 — Tue, 23 Jun 2020 03:14 GMT
  • Updated: Tue, 23 Mar 2021 20:46 GMT