On 7/31/2018 1:47 AM, Atila Neves wrote:
The only good way (I don't think the mixin template and struct solutions count)
to link to any of that today would be to have one enormous D file with
_everything_ in it, including nested namespaces.
Why doesn't it count? The user doesn't need to write that code, the translator
does. It achieves what you ask for - a declaration of foo() in the current
scope, with the mangling in the C++ namespace.
All it requires from the translator is putting a boilerplate prefix and suffix
onto what it already does.
I.e.,
extern (C++, ns) int foo();
becomes:
mixin template X() { // boilerplate prefix
extern (C++, ns) int foo(); // original line
} mixin X!() x; alias foo = x.ns.foo; // boilerplate suffix
Of course, you'd also need to write X and x as X with __LINE__ appended so
unique symbols are generated. (I know you've had trouble with generating unique
names in another post, but that's an independent problem we should find a way to
fix. Maybe instead of __LINE__, use a checksum of the original line?)