rontolisp:async-defun
(rontolisp:async-defun name (params...) body...)
Defines an asynchronous function. The surface is the same as defun — the full lambda-list keywords (&optional, &rest, &key, ...) are supported — but calling the function starts the body immediately and returns a future instead of a value: the body runs until its first rontolisp:await of an unsettled future (or until completion), then the caller resumes ("eager start"). The future settles with the values of the last body form — all of them, which await returns as multiple values — or with the error the body signaled (re-signaled when the future is awaited).
The call itself yields an opaque future (rontolisp:futurep recognizes it, and it prints as #<FUTURE>):
An error signaled by the body does not escape at call time; it settles the future and re-signals at the await — see rontolisp:await for catching it with handler-case. The anonymous counterpart is rontolisp:async-lambda. (rontolisp:async (defun name ...)) — the rontolisp:async wrapper — is an equivalent JavaScript-style spelling.
Backend support
- Interpreter / JVM: the body runs on a virtual thread — real parallelism with the caller after the first suspension.
- WASM
--component: the body compiles into a state machine; anawaitof a pending future genuinely suspends it, and the component's event loop resumes it when the awaited host operation (e.g. afetchresponse) completes. The tasks of one component instance are cooperative (single-threaded). - Preview 1 WASM: the body runs to completion immediately (no asynchronous host I/O exists there).
--no-gc: rejected at compile time.