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

Rubn where at is.this
Thu Aug 2 02:09:10 UTC 2018


On Wednesday, 1 August 2018 at 23:04:01 UTC, Walter Bright wrote:
> An example of silent hijacking:
>
>    extern (C++, "ab") void foo(long); // original code
>    ... lots of code ...
>    extern (C++, "cd") void foo(int); // added later by intern, 
> should have been
>                                      // placed in another module
>    ... a thousand lines later ...
>    foo(0); // OOPS! now calling cd.foo() rather than ab.foo(), 
> D sux
>
> You might say "nobody would ever write code like that." But 
> that's like the C folks saying real C programmers won't write:


You can do that today, just remove the "extern(C++, ...)" part 
and you have the same issue. Why should C++ with namespaces be 
safer than just regular D ? I don't understand, if it is such a 
huge gigantic problem why didn't you do anything to solve this 
problem in regards to D then ?


More information about the Digitalmars-d mailing list