This can be helpful in a number of circumstances, including but not limited to mocking in unit tests. The working plan is for a named module to only be linked to that name for any dependencies of the including module. So there can be different 'foo' modules declared throughout a project, but only as long as the "scopes" don't overlap.
However, this can create an issue where the same module might be requested with different imports.
// main.pr
import 'a.pr';
import 'b.pr';
// a.pr
define module 'z' from 'z.pr';
import 'c.pr';
// b.pr
define module 'z' from 'z2.pr';
import 'c.pr';
// c.pr
import 'z';
Now we have a conflict because c.pr was requested with 'z' defined to be both 'z.pr' and 'z2.pr'. It would be possible just to go with whichever was first, but right now I think we should make this a compilation error.
I'm currently working on the module system and going to add the ability to define a name for a module.
This can be helpful in a number of circumstances, including but not limited to mocking in unit tests. The working plan is for a named module to only be linked to that name for any dependencies of the including module. So there can be different
'foo'
modules declared throughout a project, but only as long as the "scopes" don't overlap.However, this can create an issue where the same module might be requested with different imports.
Now we have a conflict because c.pr was requested with
'z'
defined to be both'z.pr'
and'z2.pr'
. It would be possible just to go with whichever was first, but right now I think we should make this a compilation error.Give this some more thought.