Skip to content

Zeen 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:

  1. Declarations - top level code description (functions, structures, interfaces, etc.)
  2. Statements - members of declarations, contains executable sequence (annotations, assigns, calls, etc.)
  3. 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 declaration
fn 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:

Terminal window
mkdir -p docs src
touch {README.md,LICENSE,src/main.zn}
printf '%s\n' 'fn main() {' ' @println("Hello, Zeen!");' '}' > src/main.zn