Reputation: 2352
How can I avoid name conflicts among modules? From the documentation, it seems currently there is no principled name management among modules in Rascal. When importing a module, all names declared public
in the imported module come into scope. Is there a way for qualified import? Or will there be?
Upvotes: 5
Views: 139
Reputation: 6696
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:
extend
mechanism (as opposed to import
) will support renaming at extension time in the future.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).
int a = f;
(imagine f was imported from both module A and module B), you should write: int a = A::f
or int a = B::f
to resolve the ambiguity.data A = a();
from one module is merged with data A = b()
, same for syntax syntax Exp = Exp "+" Exp;
is merged with syntax Exp = Exp "*" Exp;
and for functions: int f(int i) = 1;
is merged with int f(real r) = 1;
.A::f(1)
to prevent using the merged version.int f(int i) = 1;
from one module with int f(value x) = 2;
from another.Upvotes: 4