Skip to content

Imports and Visibility

Zeen modules are just .zn files, joined by the include system. Modules connect with the use word: the compiler resolves every import by itself, links modules together and reports collisions (duplicate definitions) with both locations. The project root is the dir of the file the compilation started from (main.zn in zeen main.zn output):

  • main.zn entry file, its dir is the project root
  • Directoryutils/
    • helpers.zn reachable as root.utils.helpers (or from main: utils.helpers)

Core library is injected automatically, no use needed: Option, Result, Copy, Drop, Display, Iterator and so on are always in scope.

Names declared in core are reserved: a custom item with the same name is an error.

Dots map to directories, the last segment to a .zn file:

use std.string;
use std.c.posix.pthread;

The first segment picks the base:

Prefix Base
root project root
super parent dir of current file
std std root (--std, $ZEEN_STD or ~/.zeen/std)
(none) dir of current file
use root.utils.helpers;
use super.library;

Mentioning String or List pulls in std.string / std.collections.list automatically, no use needed. @format pulls in std.string and fat closures pull in std.fn the same way.

Items are private by default, pub opens them for other modules:

pub fn triangulate() { /* ... */ }

Accessing a private item from another module is an error.