"Andrei Alexandrescu" wrote in message
news:lhkebg$1i1p$1...@digitalmars.com...
extern (C++) template nspace() {
int foo();
}
This is really ugly and complicated.
I don't quite see how one is ugly and complicated and the other is...
pretty and simple? Anyhow de gustibus.
Stuff inside the template will only be instantiated when used. That's fine
when it's just a prototype of a C++ function to be called from D, but much
less useful when the implementation is in D and the use is from C++.
It can conflict with the eponymous template syntax - D would not be able to
tell the difference between a templated function and a function inside a
namespace with the same name.
It forces this organisation for all symbols that use C++ namespaces.
If you define functions in the same namespace in different modules the
template symbols will conflict and you will have to use fully-qualified
names.
On the other side, in D modules are used for symbol organisation. It's
powerful enough that you can get namespace::function to match
library.module.function (and I expect you can force use of the namespace
through clever use of static renamed imports).
The missing part is getting the mangling right, and a pragma is the least
intrusive way I can imagine to do that.