extern(C++, ns) is wrong

Carl Sturtivant sturtivant at gmail.com
Mon Sep 10 20:37:35 UTC 2018


On Wednesday, 5 September 2018 at 13:53:15 UTC, Jonathan M Davis 
wrote:
> On Wednesday, September 5, 2018 7:03:26 AM MDT Nicholas Wilson 
> via Digitalmars-d wrote:
>> [...]
>
> Based on everything Walter said in the previous thread, it 
> honestly seems to me to be primarily like he just can't give up 
> on the idea that D has to worry about modeling C++ namespaces. 
> Pretty much all of the extra complications that come from the 
> current approach stem from insisting on modeling namespaces in 
> D instead of just treating the namespace as part of the 
> information that you give to the compiler to indicate what the 
> symbol in D is supposed to correspond to in C++ when the 
> compiler goes to mangle it.
>
> [...]

I wholeheartedly agree. C++ namespaces are a C++ language idea 
that D has discarded in favor of much simpler facilities. 
Injecting that <expletive-deleted> back into D when linking to 
C++ is polluting D with needless complexity at odds with that 
gain in simplicity. The name collision problem with two 
namespaces containing the same name can be resolved with much 
simpler facilities. For example, at the point of the extern 
declaration, the name of the linked entity could be provided as 
an optional third parameter so that the name in D could be 
different. I'm sure many other simple schemes could be invented, 
more consistent with D's approach.



More information about the Digitalmars-d mailing list