Are aliases supossed to be implicitly cross-module overloadable?

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Aug 21 09:59:38 PDT 2010


Here's a few modules:

main.d:
import first;       // call(double)
import second;  // aliased: third.call(string) call

void main()
{ 
    call(5.5);
}


first.d:
void call(double) { }


second.d:
import third;
alias third.call call;


third.d
void call(string) { }


There's a problem here, the function "call" from module first.d is not overloaded against the functions "call" from second.d & third.d when modules first.d and second.d are imported to a separate module.

So it appears I can't implicitly overload against two modules, where one module has an alias to a function of another module. The way to work around this would be to add more aliases, this time to both modules in main.d:

import first;   // call(double)
import second;  // aliased: third.call(string) call

alias first.call call;
alias second.call call;

void main()
{ 
    call(5.5);
}

Is this how it's supossed to be? Btw, this is just a simplified version of the TDPL example, but it was a little vague on whether or not main.d needs those aliases in addition to the alias in second.d.


More information about the Digitalmars-d mailing list