Zeen Modules
Modules
Section titled “Modules”Modules in Zeen are just source code files with a .zn extension. The name of the module is just the file name without extension (no extra declarations required).
Mostly module can look like this:
fn main() { let calculation = 2 + 2 * 2;
@println("Result: {}", calculation);}Code separates into 3 different levels:
- Declarations - top level code description (functions, structures, interfaces, etc.)
- Statements - members of declarations, contains executable sequence (annotations, assigns, calls, etc.)
- Expressions - little elements of data operating (like arithmetic, comparison, literals annotation, etc.)
We can split up our previous code with these levels:
// Declarations Level
// `main` is a function declarationfn main() { // Statements Level
// annotation statement let calculation = 2 + 2 * 2 /* value expression */;
// macro call, // 2 expressions arguments: string literal, variable reference @println("Result: {}", calculation);}It’s highly recommended to use main.zn name for the entry file. Currently Zeen doesn’t have package manager
which could automatically initialize project for you. I suggest to use next template:
- README.md
- LICENSE if necessary
Directorydocs/
- …
Directorysrc/
- main.zn
To automatically initialize all these files you can run this command inside project directory:
mkdir -p docs srctouch {README.md,LICENSE,src/main.zn}printf '%s\n' 'fn main() {' ' @println("Hello, Zeen!");' '}' > src/main.zn