sleep
sleep(duration)
Input: duration · Output: no output
What it is
duration: a time quantity in any time unit (sleep(2 s), sleep(250 ms), sleep(10 us)), or a bare number, which is milliseconds (sleep(50) is 50 ms; fractions honoured). Pauses the calling thread for that long, first flushing printed output. A non-time unit (sleep(3 V)), a negative or a non-finite duration is an error. *Units accepted since v0.4.4.* Returns none.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
sleep(duration) | duration numbernot documented yet | not documented yet | Pauses the calling thread for that long, first flushing printed output. *Units accepted since v0.4.4.* Returns none. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
n = 0
watch file("data.csv") do
n = n + 1
end
wait until n >= 1
sleep(200) # real wall-clock pause between checks
pump_watches()
end until
from tour
square(x) := x * x
function run_listener()
listen_pool(9321, allow=("square"))
end function
w = spawn("run_listener") # the "remote" side, on its own thread here
sleep(0.3) # give it time to bind before connecting
pool workers with cpu=1, remote=("127.0.0.1:9321")
end pool
q = queue()
for i in 0 to 4
q.push("square", i)
end for
results = run q on workers # some local, some "remote" — one ordered List
print(results) # (0, 1, 4, 9, 16)
from concurrency
How it works
sleep(ms) (§ wait until / sleep, scoped 2026-08-26) — a REAL OS sleep (std::thread::sleep), not a simulated- timeline wait like every/after/at's run_for virtual clock. This is the one piece that makes wait until COND ... end until actually usable instead of busy-spinning a CPU core at 100%: wait until is plain sugar for a while loop (see qu-syntax's wait_until_stmt), and a while loop re-checking a condition with no delay between checks has no way to yield the CPU without this. Blocks only the calling thread — doesn't touch pool/run's worker threads, produces no value, and consults no RNG state, so it doesn't interact with seed(n)/order-stable-reduction determinism at all; it's real wall-clock time, which this codebase already accepts as inherently non-reproducible elsewhere (tic/toc).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.