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

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 29 14:38:07 PDT 2014


On 04/29/2014 10:49 PM, Steven Schveighoffer wrote:
> On Tue, 29 Apr 2014 16:00:43 -0400, Steven Schveighoffer
> <schveiguy at yahoo.com> wrote:
>
>> On Tue, 29 Apr 2014 15:52:01 -0400, Walter Bright
>> <newshound2 at digitalmars.com> wrote:
>
>>> Because the compiler would now issue an error for that, it's its
>>> anti-hijacking feature.
>>>
>>> Try it and see!
>>
>> I agree! that was my central point, which Timon seemed to be arguing
>> against :)
>
> And in fact, so were you!
> ...
>
> This is EXACTLY the same code that you said would now be an error above!

Maybe he didn't notice that you changed the 'main' function relative to 
my post. If you don't mention 'foo' explicitly, then obviously it cannot 
be hidden by the import and the code is in error.

>
> I think you guys  need to reexamine this,

Not me. I typically test my claims even if I am sure, if only to file 
bug reports.

> and choose one way or another.
> At this point, I have no clue as to how it's supposed to work.
>

Obviously you did not actually try. :P

Again, to make it really easy for you to test the behaviour:

module foo;
import std.stdio;

int func(){ writeln("hello from foo!"); return 1; }

//---

module bar;
import std.stdio;

mixin template X(){
     int func(){ writeln("hello from bar!"); return 2; }
}
mixin X foo;

//---

module prog;

void main(){
     void onlybar(){
         import bar;
         auto r=foo.func(); // hello from bar!
         assert(r==2); // pass!
     }
     void fooandbar(){
         import bar,foo;
         auto r=foo.func(); // hello from foo!
         assert(r==1); // pass!
     }
     onlybar();
     fooandbar();
}


http://dlang.org/download.html

$ dmd prog foo bar && ./prog
hello from bar!
hello from foo!

This is because the import of module 'foo' hides the namespace 'foo' 
imported from 'bar' in the scope of 'fooandbar'. It is not 'func' that 
is being hidden, but 'foo'.



More information about the Digitalmars-d mailing list