On Mon, 28 Apr 2014 17:00:11 -0400, Simen Kjærås via Digitalmars-d <digitalmars-d@puremagic.com> wrote:

On 2014-04-28 20:50, Walter Bright via Digitalmars-d wrote:
On 4/28/2014 7:27 AM, Steven Schveighoffer wrote:
Consider this code:

module foo;

void func() {}

module bar;

extern(C) func();

module prog;

import foo;
import bar;

void main()
{
    func(); // error
    foo.func(); // ok
    bar.func(); // ok, uses C binding (no name mangling)
}

In this case, even though the C function is not mangled or in any other
namespace, the module can be used for unambiguous calling.

Right.


module foo;

void func() {}

module bar;

extern(C++, foo) void func(); // foo::func in C++ land

module prog;

import foo;
import bar;

void main()
{
    func(); // error
    foo.func(); // ALSO error

No, not an error. Why would it be?

I believe Steven expects things to work this way:

module bar;

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


module prog;

import bar;

void main()
{
    foo.func(); // Calls bar.func (or is that bar.foo.func?)
}

Yes, exactly. That is what the DIP says:

"Declarations in the namespace can be accessed without qualification in the enclosing scope if there is no ambiguity. Ambiguity issues can be resolved by adding the namespace qualifier"

Which then proceeds to show that only the namespace qualifier is needed to disambiguate the symbol.

-Steve

Reply via email to