Dz
Djazair
v1.0.5
🔍

Lang Module

Import using: use lang. Provides runtime introspection utilities, error isolation, and standard library queries.

Runtime Info

  • lang.version() - Runtime engine version string (semver).
  • lang.memoryUsed() - Current heap memory usage in bytes.
  • lang.gc() - Trigger explicit garbage collection cycle.
use lang
print(lang.version())
print(str(lang.memoryUsed()) + " bytes")
lang.gc()
print(str(lang.memoryUsed()) + " bytes after GC")

Control

  • lang.panic(message) - Unconditionally halt execution with error message.
  • lang.safeRun(func, defaultVal?) - Execute function with error isolation. Returns defaultVal if function throws.
use lang
# safeRun catches errors
let result = lang.safeRun(fn() throw "err" end, "fallback")
print(result)  # fallback

# Without default, returns Null on error
let result2 = lang.safeRun(fn() throw "err" end)
print(str(result2))  # Null

# lang.panic("This would halt execution")

Introspection

  • lang.disassembler(fn) - Disassemble closure bytecode into human-readable instructions. Returns string.
  • lang.arity(fn) - Returns number of formal parameters of a function.
  • lang.moduleMembers(mod) - Returns a Map of all exported symbols from a Module or Library. Keys are symbol names, values are the symbols themselves.
  • lang.sysLog(level, message) - Write timestamped log entry to stdout.
use lang
let add = fn(a, b) a + b end
print(str(lang.arity(add)))  # 2
lang.sysLog("INFO", "System ready")

# Inspect a module's exports
use file
let syms = lang.moduleMembers(file)
for s in syms.items()
    print(s[0] + " -> " + type(s[1]))
end

Library Paths & Queries

  • lang.stdDir() - Standard libraries directory path.
  • lang.libsDir() - Extensions directory path.
  • lang.stdLibs() - Array of standard library descriptors.
  • lang.extensions() - Array of extension descriptors.
use lang
print(lang.stdDir())
print(lang.libsDir())
let libs = lang.stdLibs()
print(str(libs.length()) + " standard libraries available")
© 2026 Harizi Riyadh. Released under the MIT License.
Official Website for Djazair.