DIP61: redone to do extern(C++,N) syntax

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 29 09:03:02 PDT 2014


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.

> If it doesn't work, well, then I
> see nobody using this feature (using C++ namespace for disambiguation,
> not the mangling, which is still useful).
>
> -Steve

The name disambiguation feature fundamentally addresses one simple 
issue, namely the case when the same name occurs in multiple different 
namespaces occurring in the same module. (It is trivial to implement in 
a compiler, if that helps, because there is no new machinery, just share 
the implementation with named mixin templates.)


More information about the Digitalmars-d mailing list