Modules will allow great reuse of code behind simple hierarchical names.
The whole thing creates a simple tree which can then be queries/updated to locate various identifiers.
In this module system, every .zc file is a module unit, containing at most one export clause and multiple (possibly zero) import clauses.
The export clause is used to specify which identifiers "given" to the importing module.
A simple grammar may just be export_clause ::= 'export' '(' identifier*_',' ')', however we may consider multiple extensions (e.g. separating effect, typeclass, implementations, etc extensions) but this will be dealt with later.
The import clause allows importing identifiers specified by modules with optional renaming of identifiers.
An import path is a ::-separated list of valid identifiers (not containing any _).
The global syntax for import clauses is as follows: import_clause ::= 'open'? 'import' import_path ('as' identifier)? '(' (identifier ('as' identifier)?)*_',' ')'.
import clauses can be opened, meaning all imported identifiers are available in the scope.
They may as well be aliased, creating a "new" import path accessible using the :: syntax (e.g. my-module::some-fn(0)).
Semantically, import clauses search for a corresponding file/subfile in the current include path, while export clauses make available a module relative to the include path.
Cyclic imports (e.g. "A imports B and B imports A") are not supported (as well as multiple modules with the same name in the include path).
If the export is left missing, the module is assumed to expose no definition in the file.
Modules will allow great reuse of code behind simple hierarchical names. The whole thing creates a simple tree which can then be queries/updated to locate various identifiers.
In this module system, every
.zc
file is a module unit, containing at most oneexport
clause and multiple (possibly zero)import
clauses.The
export
clause is used to specify which identifiers "given" to the importing module. A simple grammar may just beexport_clause ::= 'export' '(' identifier*_',' ')'
, however we may consider multiple extensions (e.g. separating effect, typeclass, implementations, etc extensions) but this will be dealt with later.The
import
clause allows importing identifiers specified by modules with optional renaming of identifiers. An import path is a::
-separated list of valid identifiers (not containing any_
). The global syntax forimport
clauses is as follows:import_clause ::= 'open'? 'import' import_path ('as' identifier)? '(' (identifier ('as' identifier)?)*_',' ')'
.import
clauses can be opened, meaning all imported identifiers are available in the scope. They may as well be aliased, creating a "new" import path accessible using the::
syntax (e.g.my-module::some-fn(0)
).Semantically,
import
clauses search for a corresponding file/subfile in the current include path, whileexport
clauses make available a module relative to the include path. Cyclic imports (e.g. "A imports B and B imports A") are not supported (as well as multiple modules with the same name in the include path). If theexport
is left missing, the module is assumed to expose no definition in the file.