Is there any good reason why C++ namespaces are "closed" in D?

Manu turkeyman at gmail.com
Sun Jul 29 20:46:34 UTC 2018


On Sun, 29 Jul 2018 at 04:04, Jonathan M Davis via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> 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.

Or extern(C), or extern(C++), or extern(ObjectiveC)...


More information about the Digitalmars-d mailing list