Nathan-Wall / proto

A programming language derived from JavaScript which emphasizes prototypes, integrity, and syntax.
Other
12 stars 1 forks source link

Same module different circumstances conflict #86

Open Nathan-Wall opened 10 years ago

Nathan-Wall commented 10 years ago

I'm currently working on the module system and going to add the ability to define a name for a module.

// main.pr
define module 'foo' from 'foo/bar/baz.pr';
import 'bing/bop.pr';
// bing/bop.pr
import 'foo'; // imports '../foo/bar/baz.pr'

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.

Give this some more thought.