Skip to main content

Module system

Module system 

Source
Expand description

Opt-in system builtins for the interpreter.

Kept separate from the pure builtins module so a Terreiro used as a sandbox stays I/O-free by default. tatara-init --eval and any other host-side embedder calls Interpreter::new_with_system() to enable these side-effecting primitives:

  • (print v) — write stringified v to stdout
  • (println v) — print + newline
  • (eprint v) — stderr
  • (eprintln v) — stderr + newline
  • (sleep seconds) — block for seconds (integer or float)
  • (exit code) — std::process::exit
  • (env name) — std::env::var
  • (env-or name def) — env with fallback
  • (read-file path) — returns string
  • (write-file path content) — returns nil
  • (shell cmd) — run /bin/sh -c cmd, return exit code as int
  • (forever body…) — loop the body forever (no natural exit; SIGINT)

forever is a special form: it doesn’t eagerly evaluate its arguments (otherwise the first invocation would wedge at eval time). Handled inside the Interpreter’s list dispatch, not here.

Functions§

system_builtin_table