zedocs
GitHub ↗
Language

Modules & imports

Organize Ze applications with source modules and relative imports.

Split an application into .ze files and import them at the top level:

apil "src/routes.ze"
atimana()

apil (Bisaya), isama (Tagalog), and import (English) are equivalent. An import takes a quoted .ze path, relative to the file containing it, using / separators. Nested modules can use ../ to reach sibling folders, provided the resolved path stays inside the entry file’s directory. Absolute paths are rejected.

Modules execute once per program load, in dependency order. Circular imports and missing files fail during loading, with the import file and line in the error. Imports inside functions or conditional blocks are rejected.

Modules currently share the program’s global scope. Use distinct function names across modules; there are no namespaces or export declarations yet. Prefer modules that define functions, with startup calls in the entry file.

Run an application using Ze path/to/server.ze. Go hosts use core.LoadProgram or core.LoadProgramFS (which supports embed.FS). core.InterpretFile loads and executes a file with the standard library. core.Interpret(source) and the REPL have no file context and do not resolve imports.

The Ze-Backend application uses routes (src/routes.ze), controllers (src/controllers/), validation (src/validation/), database operations (src/repositories/), and response helpers (src/helpers/). Its HTTP launcher loads the whole dependency tree before listening.

Serve that application directly with ze serve from its folder, or ze serve --entry path/to/server.ze. ze start is an alias. The Ze runtime owns HTTP startup, the request adapter, and SQLite initialization. schema.sql and the default tasks.db resolve relative to the entry file. Use --host, --port, --addr, --db, and --schema to override settings. Watch mode automatically reloads edited .ze files and imports. Use —watch=false to disable it. Configuration and schema changes require a restart. The backend needs no Go files or separate compilation. The previous Ze -serve path/to/server.ze syntax still works.

Help make these docs better.Edit this page on GitHub ↗

Find a guide or search the language reference.