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

bachmeier no at spam.net
Thu Aug 2 11:51:50 UTC 2018


On Thursday, 2 August 2018 at 04:59:52 UTC, Walter Bright wrote:

> The difference is those names are supposedly in different 
> namespaces, given that the code is converted from C++:
>
>     namespace ab { void foo(long); }
>     ... lots of code ...
>     namespace cd { void foo(int); }
>
> where the foo()'s do not conflict with each other, and a user 
> would reasonably expect that same behavior when translated to D.

This is a trivial problem to solve.

mangle(C++, ab) { void foo(long); }
mangle(C++, cd) { void foo(int); }

It's certainly not obvious to me why anyone would do that, write

foo(3);

and then blame you when it doesn't work.


More information about the Digitalmars-d mailing list