On 3 January 2016 at 15:45, Walter Bright via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
> On 1/2/2016 9:19 PM, Manu via Digitalmars-d wrote: > >> In addition to that rant, extern(C++) seems to fail at forward >> referencing. Any >> time I have 2 modules that refer to eachother, suddenly the order of >> everything >> is critical. I can sometimes resolve these problems by moving imports out >> of the >> global scope, but often it's terminal, and I need to restructure >> everything in >> awkward and unnatural ways to break the stalemate. >> >> I know I'll just get complaints from people to submit bugs; I have submit >> lots, >> and in many cases, I've tried to, but they're almost impossible to >> produce in >> isolation, only when a project gets 'real', ie, big enough that it's >> realistic >> in scope does it all start to break down. It's really hard to reduce a >> bug that >> I don't understand, somewhere among a program with 30-ish interconnected >> modules. It's worse when the structure of the project is unnatural, a >> requirement forced by the namespace issue, and everything is already >> really >> brittle as a result. >> >> The thing is, it almost all comes back to the pseudo-namespaces >> (sprinkled with >> weird forward referencing issues). Maybe it sounded good at the time, but >> it >> doesn't work in practice. If that was fixed, then we'd stand on solid >> ground, >> and it might be possible to reduce bugs and move forward in that >> environment. >> > > They're not pseudo-namespaces. C++ namespaces in D are scoped namespaces > and follow all the D scoping and name lookup rules. They are mangled, > however, like C++ namespace scoped symbols are mangled. > I don't want that. That's what modules are for. extern(C++) should only state where the external C++ function is to be found. If the user wants the D symbol under a namespace to match C++, let them do so explicitly. But they probably already are via the module scope. Given a C++ symbol 'NS::CSymbol', the D symbol 'x.y.NS.CSymbol' bears no meaningful relation. D still prefixes the module scope. The user will almost certainly instead do: module NS; // a module for the C++ thing extern(C++, NS) void func(); Which would give them the symbol 'NS.NS.func'. Surely what they intended was 'NS.func' to match the C++ symbol? I am not aware of any forward reference issues with C++ namespaces, so > without an example, I cannot do anything. > https://issues.dlang.org/show_bug.cgi?id=15389 Over a month ago, nearer to the start of my descent into madness. I suspect this had lead to some mis-diagnoses of issues.