Modules
Autolang uses a deterministic, compile-time module system based on the @import(string) directive. Imports declare dependencies explicitly before execution, ensuring the compiler validates all symbols up front.
Standard Library Modules
Built-in standard library components are imported using the std/ prefix. Built-in types such as Array, Map, and Set are part of the core language and do not require any import.
| Module | Description |
|---|---|
| std/math | Mathematical operations, trigonometry, constants, and random generation. |
| std/date | Date parsing, formatting, arithmetic, and timestamps. |
| std/time | High-resolution benchmarking, timers, and sleeping. |
| std/json | JSON parsing, serialization, and typed DTO decoding. |
| std/file | Bounded file I/O operations and directory traversal. |
| std/bytes | Raw byte buffers, Hex, and Base64 conversions. |
| std/regex | Regular expression matching, searching, and replacing. |
| std/http | Sandboxed synchronous and concurrent HTTP requests. |
@import("std/math")
@import("std/date")
val currentDate = Date.now()
println("Today: " + currentDate.toDateString())
println("Square root of 81: " + Math.sqrt(81.0))Host Capability Modules
The host application registers business capabilities into the compiler (for example, CRM, ERP, or billing bindings). Scripts access them cleanly using standard @import declarations without managing credentials.
// Registered by the host application environment
@import("crm")
@import("payment")
val customers = crm.getSegment("enterprise")
payment.authorizeBatch(customers)Local File Imports
Separate helper routines into modular files. Local imports are resolved relative to the calling script using ./ or ../.
@import("./services/accounting")
@import("../common/types")
val ledger = AccountingLedger()
ledger.sync()Security Guarantees
The module system strictly enforces security boundaries:
- Compile-time verification: All imports are checked before any line runs.
- Zero dynamic evaluation: There is no
eval()or dynamic module loading at runtime. - String literal requirement: Import paths must be static string literals known at compile time.