Good question again :-) The short answer is you qualify the names at the use sites in the module that has imported the same name twice.
The long answer is three-fold:
- The
extend
mechanism (as opposed toimport
) will support renaming at extension time in the future. - When two names clash, in the sense that there is an ambiguity due to
import
ing two modules that use the same name, the name is to be qualified at the use site in the current module. The type checker will suggest something appropriate (when it is released).- For example in this ambiguous code:
int a = f;
(imagine f was imported from both module A and module B), you should write:int a = A::f
orint a = B::f
to resolve the ambiguity.
- For example in this ambiguous code:
- For non-overlapping functions, algebraic data-types and syntax non-terminals clashes do not exist, they are merged.
- For example:
data A = a();
from one module is merged withdata A = b()
, same for syntaxsyntax Exp = Exp "+" Exp;
is merged withsyntax Exp = Exp "*" Exp;
and for functions:int f(int i) = 1;
is merged withint f(real r) = 1;
. - On that note, you could still refer to one of the alternatives using:
A::f(1)
to prevent using the merged version. - And overlapping functions will still require disambiguation, when the parameter patterns are not mutually exclusive (an example would be:
int f(int i) = 1;
from one module withint f(value x) = 2;
from another.
- For example: