Scripting & runtime · utilities
Time, sleep, secure randomness and output.
Small native runtime utilities: wall-clock epoch milliseconds, a blocking sleep, an identity-preserving monotonic stopwatch, operating-system secure random bytes, and execution-scoped output streams.
Time and sleep
now := epoch() // Unix epoch milliseconds (integer)
sleep(250) // blocks this execution thread for 250 ms, returns null
epoch() returns integer Unix milliseconds. sleep(ms) blocks the current execution thread for a non-negative signed-64-bit duration and returns null.
Monotonic stopwatch
timer() returns a stopped monotonic stopwatch with opaque, identity-preserving semantics. Copying or passing the handle preserves identity.
t := timer()
t.start()
sleep(10)
print(t.elapsed()) // elapsed milliseconds
t.pause()
t.resume()
t.stop()
t.reset()
print(t.running()) // false
print(t.paused()) // false
Methods: start(), elapsed(), pause(), resume(), stop(), reset(), running(), paused(). Timer handles are Parser-local: they are rejected at rendering, embedding, serialization, and thread/future transfer boundaries.
Secure random bytes
secure_random_bytes(n) returns up to 10,000,000 bytes from the operating-system CSPRNG, with no fallback pseudorandom generator. The bytes use ordinary (non-erased) heap storage, and using them in a template makes the generated output nondeterministic.
token := secure_random_bytes(32) // 32 random bytes
print(token.size()) // 32
Execution output streams
Runtime output uses execution-scoped stdout and stderr sinks. err(value) writes one atomic line to stderr with the same value rules as print(value). Embedding captures stdout and stderr separately per operation, on success and on failure, and keeps them distinct from return values, diagnostics, and rendered content. Worker output is inherited from the owning execution and written atomically.