Is there any good reason why C++ namespaces are "closed" in D?
Manu
turkeyman at gmail.com
Sun Jul 29 20:45:03 UTC 2018
On Sun, 29 Jul 2018 at 01:30, Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> 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.
You're really reaching here. Of course, this error is legitimate and correct.
Any D programmer knows they can't do this, and why would they expect they could?
There's no way you'll get a bug report from someone complaining they
can't multiply define symbols in the same scope. That's common sense.
They will intuitively move the second declaration into a second module.
...or they'll use your existing mechanism; it's in there now, we can't
remove it.
But please support a variant where we can specify namespace as a
string and opt-out of any funny business with scoping.
More information about the Digitalmars-d
mailing list