Specifying C++ symbols in C++ namespaces

Walter Bright newshound2 at digitalmars.com
Sat Apr 5 13:47:32 PDT 2014


On 4/2/2014 3:07 PM, Walter Bright wrote:
> One downside of this proposal is that if we ever (perish the thought!) attempted
> to interface to C++ templates, this design would preclude that.

Yes, this seems to be a fatal flaw. Another design that has evolved from these 
discussions and my discussions with Andrei on it:

     extern (C++, namespace = A.B) { void foo(); void bar(); }
     extern (C++, namespace = C) void foo();

     bar();  // works
     A.B.bar(); // works
     foo(); // error: ambiguous
     C.foo();   // works

     alias C.foo foo;
     foo();  // works, calling C.foo()

I really think the namespace semantics should be attached to the extern(C++) 
rather than be a separate pragma. Having the namespace= thing means that 
namespace isn't a keyword, and provides a general mechanism where we can add 
language specific information as necessary.


More information about the Digitalmars-d mailing list