O Language

Modules and loading

Load reusable O Language source and understand the web project's generated module loader.

O Language pagesModules and loading
On this page

The load form reads and evaluates another source file in the current program environment. Modules commonly use the .olm extension, though the loader reads the path supplied to it.

load "lib/settings.olm"

Resolve paths from the process working directory. They are not automatically relative to the file that contains the load statement. Start the program from its project directory or use a path that matches the directory you choose.

Share definitions

Put reusable functions and values in a module, then load that module before using them. The file is evaluated in the caller’s environment; this is source loading, not an isolated package namespace.

The current loader does not provide a separate import/export declaration. Avoid assuming module isolation or automatic dependency resolution from the .olm extension.

Web project loader

The web scaffold uses boot.ola to load lib/loader.olm, then starts the configured HTTP server. The central loader loads controller and configuration files; generated web CLI commands add component files to it.

load "lib/loader.olm"

webserver("10000", config)

Keep controller definitions loaded before the route table that references them. The Web Framework guide describes the generated directory layout and project files lists the conventions.

Next

Continue with advanced runtime behavior or web programming.