On Wednesday, 20 January 2016 at 20:56:49 UTC, Walter Bright wrote:
On 1/20/2016 4:17 AM, Manu via Digitalmars-d wrote:
You claim this is a problem that must desperately be solved:
------------------------------------
int x;
extern(C++, ns) int x;
------------------------------------

The solution arrives at basically the same problem:
------------------------------------
int ns;
extern(C++, ns) int x;
------------------------------------

We've just robbed peter to pay paul?

C++ doesn't allow:

    int ns;
    namespace ns { ... }

either, so there can never be a need to solve that problem.

In Manu's example, `int ns` is a native D variable, not an extern(C++) one.

The C++ code you responded with has no relevance to whether Manu's example could or should work; it's entirely determined by the design of the D compiler.

More generally, the basic purpose of `extern(C++)` is simply to indicate that a D identifier should be mapped to a certain C++ symbol.

It makes no sense to insist that the D identifier *must* be derived from the C++ symbol in a some specific way (that is, by including the C++ namespace in the D identifier) to make the problem tractable. If you wanted to, you could easily make the mapping totally arbitrary with something like `pragma(mangle)`.

Given that the mapping could be anything you choose, how can D's identifier disambiguation facilities be adequate for native D symbols, and yet not for C++ symbols? Why must there be any difference between the two at all?

Reply via email to