Modules

AutoLang uses a compile-time module system based on the @import(string) directive. Modules can reference either built-in standard libraries or local files.

Import syntax

@import("./utils") @import("../core/math")

The argument must be a string literal known at compile time.

Standard Library

Built-in libraries provided by the compiler are imported using the std/ prefix. These modules are resolved internally and do not correspond to physical files in the project.

val a: Array<Int> = Array<Int>() println(a)

Example built-in modules:

  • std/vm
  • std/time
  • std/math

Local File Imports

Local modules are resolved relative to the current file using ./ and ../.

@import("./helpers") @import("../models/user")

The compiler resolves these paths during compilation and merges module contents into the current compilation unit.

Module Behavior

  • Imports are processed at compile-time.
  • No runtime module loading.
  • No dynamic imports.
  • Import paths must be string literals.

Example Project Structure

project/ ├── main.atl ├── utils.atl └── models/ └── user.atl

In main.al:

@import("./utils") @import("./models/user") fun main() { println("Program started") }

Design Notes

The module system is intentionally simple. It avoids runtime overhead and keeps compilation deterministic. Standard modules (std/...) are embedded into the compiler, while relative imports map directly to source files.