On Sunday, July 29, 2018 2:28:08 AM MDT Walter Bright via Digitalmars-d wrote: > On 7/29/2018 1:15 AM, Manu wrote: > > All we're asking for is that C++ namespaces do **nothing** except affect > > the mangling. > > If I do that, the next bug report will be: > > extern (C++, "ab") { void foo(); } > extern (C++, "cd") { void foo(); } // Error, foo() is already declared > > foo(); // which one gets called? > > The reason namespaces were added to C++ is to not have such name > collisions. Namespaces in C++ introduce a scope. D cannot interoperate > with this without introducing a scope as well.
I guess that the argument at that point is that you would have to put them in separate D modules, just like you would if they were extern(D) functions. If that were the only problem, then that doesn't sound like a big one - especially if the documentation made it very clear that extern(C++) declarations did not affect the lookup rules, thus forcing you to rely on D's module system to deal with it all. All the extern(C++, NS) stuff does at that point is to enable linking with C++ and forces all of the normal D rules, which at least _sounds_ like it would be straightforward. If anything, it seems like it would make things much simpler. However, I've done nothing with C++ namespaces in D thus far. So, I really can't comment on the problems beyond what I've read in threads like this one. - Jonathan M Davis