We need syntax to make things from other modules accessible. This proposal shows a possible solution.
[ ] Parser parses import syntax
[ ] Parser parses export syntax
[ ] Identifiers in AST need to be replaced with Paths (module path + identifier)
[ ] Compiler needs to process imported files (once)
implementation
import and export are top-level constructs and cannot exist inside of blocks, however they can be placed at any position within a file. There are no syntax for default exports or imports as this leads to issues when IDEs try to refactor code.
Allowed exports and imports are:
Functions
Structs
example
index.xs
import { Foo, Bar } from other_module;
struct Foobar {
x: Foo;
y: Bar;
}
File resolution is a tricky thing for module systems. How do we resolve the standard library? How do we resolve libraries from a potential package manager?
Module identification:
-- packages have ids, e.g. 'xsstd'
-- import like "import * from 'xsstd' or 'xsstd/submodule'
-- resolution order: first packages, then local
Syntax proposal
We need syntax to make things from other modules accessible. This proposal shows a possible solution.
implementation
import
andexport
are top-level constructs and cannot exist inside of blocks, however they can be placed at any position within a file. There are no syntax for default exports or imports as this leads to issues when IDEs try to refactor code.Allowed exports and imports are:
example
index.xs
other_module.xs
export syntax
export a single item
export multiple items
import syntax
import a single item
import multiple items
import all
import from submodules
file resolution
File resolution is a tricky thing for module systems. How do we resolve the standard library? How do we resolve libraries from a potential package manager?
other module systems