Modules & Code Organization
Djazair provides two distinct import mechanisms: import for user-defined script files, and use for built-in standard library modules.
Importing Local Files (import)
Suppose you have a utility file named math_utils.dz:
djazair
# math_utils.dz
fn square(x)
return x * x
end
fn cube(x)
return x * x * x
end
You can import it in your main script using three different styles:
djazair
# 1. Standard import (module namespace matches filename)
import "math_utils.dz"
print(math_utils.square(5)) # => 25
# 2. Named alias import
import "math_utils.dz" as mu
print(mu.cube(3)) # => 27
# 3. Wildcard import (imports all top-level functions directly)
import "math_utils.dz" as *
print(square(4)) # => 16
Standard Library Imports (use)
Standard library modules are loaded with the use keyword:
djazair
# Standard import
use json
use math
let parsed = json.decode('{"val": 16}')
print(math.sqrt(parsed["val"])) # => 4.0
# With alias
use datetime as dt
print(dt.now().format("%Y-%m-%d"))
# Wildcard stdlib import
use math as *
print(ceil(3.14)) # Direct access to ceil()