On Tue, 29 Apr 2014 12:03:02 -0400, Timon Gehr <[email protected]> wrote:

On 04/29/2014 05:52 PM, Steven Schveighoffer wrote:
I am not familiar with the rules.

Perhaps you can just outline for me:

module bar;

extern(C++, foo) void func();

module prog;

import bar;

void main()
{
    foo.func(); // works?
}

If this works, then we have a problem.

It does work. What happens is analogous to:

module bar;

void func(){}

module prog;
import bar;

void func(){}

void main(){
     func();
}

I.e. if you add a new symbol to your own module, then this identifier will be hidden, no questions asked. Importing a module adds a new symbol of its name to your module. I'm not sure why you see this as a problem. The name lookup rules are designed such that changes in one module cannot silently change name lookup in _another_ module, but anything may happen to lookup in the same module.

OK, so you are saying that from a module different than the one that defines the namespace/function, I can call it via it's full namespace.

But what happens when you add another import that conflicts?

module foo;

void func() {}

module prog; // updated
import bar;
import foo;

void main(){
foo.func(); // now calls foo.func, and not bar.func as it originally did, right?
}

So by importing from another module, we have silently and drastically changed the behavior. Have I missed something?

Why is this not a problem?

-Steve

Reply via email to