extern(C++, NS)

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Nov 29 04:49:18 PST 2015


On Sunday, 29 November 2015 at 04:57:28 UTC, Walter Bright wrote:
> D does not support C++ semantics. You cannot split namespaces 
> into multiple files in D, nor can you add symbols to an 
> existing namespace. For namespace NS, all the declarations in 
> NS have to be in one file and between the { }, just like any 
> other scope in D.

While I don't disagree with trying to limit how much of C++ gets 
dragged into D to support linking with C++ code, I don't see how 
this approach with namespaces is tenable in anything much more 
complicated than a toy example. C++ namespaces aren't used at all 
like D modules. Entire libraries are put into a single namespace. 
For instance, are you suggesting that we put all of the bindings 
for C++'s standard library in a single file? Large libraries such 
as Boost or Qt do often split up their namespaces into 
sub-namespaces, but they're still usually far larger than anyone 
would want to stick in a single file.

It seems to me that the only way that the current behavior stands 
any chance of being tenable is if almost no one is using C++ 
bindings, and when they do, they keep them to an absolute bare 
minimum. It certainly doesn't fly well with binding something 
like the STL or Qt.

- Jonathan M Davis


More information about the Digitalmars-d mailing list