Imports bring external modules, built-ins, and local package files into the current scope.
Use the use keyword to import modules:
use math
use json
Imported modules are scoped as namespaces:
result = math.sqrt(16)
say result # 4.0
- Standard Library: Looked up automatically by the compiler. Standard modules include
math,json,crypto,fs,os,random, anddate. - Local Files: Imported relative to the current file.
use helper # Looks for helper.txs in the current directory
You can rename imports to avoid name collisions:
use math as m
say m.abs(-5) # 5
For packaging structure details, see Packages.