O Language/Advanced/Modules: Difference between revisions

From OnixOS
Created page with "= Modules and Loading = Modules use the <code>.olm</code> extension. A module can define functions and values that become available to the program that loads it. <pre> load "helpers.olm" </pre> The path is resolved from the current project directory. Keep shared definitions in modules instead of repeating them in every entry point. == Web project loading == Web projects use one central loader: <pre> load "lib/loader.olm" </pre> <code>boot.ola</code> loads <code>li..."
 
m Protected "O Language/Advanced/Modules" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
 
(No difference)

Latest revision as of 07:31, 25 August 2026

Modules and Loading

Modules use the .olm extension. A module can define functions and values that become available to the program that loads it.

load "helpers.olm"

The path is resolved from the current project directory. Keep shared definitions in modules instead of repeating them in every entry point.

Web project loading

Web projects use one central loader:

load "lib/loader.olm"

boot.ola loads lib/loader.olm. The loader loads controllers, models, connections, libraries, and finally config/config.ola. Controllers must be loaded before the route configuration because route responses refer to handler functions.

When the web CLI creates or adds a project component, it updates the loader automatically. This keeps the boot process in one place.