Modules
A module is a Letlang source file that MUST start with the module declaration statement.
Syntax
module_declaration_statement
Show source
module_declaration_statement
= "module" module_path ";"
module_path
Show source
module_path
= identifier ("::" identifier)*
Example
module foo::main;
# ...
Imports
Other modules can be imported in the current module scope, and optionnally aliased.
Symbols from other modules can be imported in the current module scope, and each of them can be optionnally aliased.
Syntax
import_statement
Show source
import_statement
= ( "import" module_path ("as" identifier)? ";")
/ ( "from" module_path "import" "{" import_symbol ("," import_symbol)* ","? "}" ";")
import_symbol
Show source
import_symbol
= identifier ("as" identifier)?
Examples
import std::io as stdio;
from std::proc import { self, send as send_message };
To access a symbol in an imported module, the complete path to the symbol is required:
symbol_path
Show source
symbol_path
= identifier ("::" identifier)*
Example
stdio::println("hello world");
import std::io as stdio;
import std::proc;
let pub main: func[() -> @ok] {
() -> {
stdio::println(std::proc::self());
@ok;
},
};