Skip to content

Lifecycle and output

Apps run in separate processes. Use Run to start one, Await to wait for completion, and Show to display its captured Output.

Build checks readiness, Run launches, Stop requests termination, and Await joins final outputBuild checks readiness, Run launches, Stop requests termination, and Await joins final output
Open full-size diagram. The surrounding prose explains the boundaries.
FormEffect
BuildCheck an already compiled companion; no runtime compilation
RunStart an App without waiting for completion
StopRequest forceful termination without waiting for completion
AwaitJoin the finalized result; activate its continuation once
StartSource-defined Build then Run
ExecuteSource-defined Start then Await
OutputRead finalized raw stdout without waiting
ErrorInspect an operation or App failure

Start and Execute accept any App.

Keep an invocation outstanding until Await finishes

Section titled “Keep an invocation outstanding until Await finishes”

Wait for the first Await continuation to finish before running the App again. Repeated Await returns the same result without repeating the continuation. Aliases refer to the same App and share its current run.

demo/paragraphs/repeated-activation.l
Use IO's Print from `io` as "Print".
"message" is `Repeat`.
Create "Repeat" as a New Public Basic App.
The App Prints message.
Define "result" as Repeat's Output.
Show result.
Show result.
Use Repeat as "Worker".
Run Worker.
Await Worker.
Define "snapshot" as Repeat's Output.
Run Worker.
Await Worker.
Show snapshot.
Show Repeat's Output.

Complete program. Source: demo/paragraphs/repeated-activation.l.

Example evidence

Later invocation and retained scalar/output snapshots. existing-witness-not-run. Evidence guide.

Worker aliases Repeat. Each run gets fresh continuation locals. The final two Shows read a saved snapshot and the latest Output separately. Together, the program writes six Repeat\n lines.

Output preserves stdout bytes and newlines. Stderr is captured separately and is not forwarded automatically. An App failure becomes a stored result that the program can inspect.

This example gives Worker a continuation that shows error| or success|, then performs:

testdata/phase1/language/lang-10.l (lines 9–14)
Run Worker.
Stop Worker.
Show `stop-requested|`.
Await Worker.
Await Worker.
Show `joined|`.

Fragment. Source: testdata/phase1/language/lang-10.l (lines 9–14).

Example evidence

Stop/Await ordering excerpt; Worker and its Error-checking continuation are declared earlier. Existing native witness permits termination or normal-completion race outcomes. existing-witness-not-run. Evidence guide.

Stop does not wait: Await still joins the result and runs the continuation. A short-lived App can finish before Stop reaches it, so either success or termination is possible.

Reading Output does not wait. Use Await first to ensure completion, and remember that Print's trailing newline remains in Output.

demo/paragraphs/run-within-paragraph.l
Use IO's Print from `io` as "Print".
"message" is `Inner`.
"otherMessage" is `Other`.
Create "Worker" as a New Public Basic App.
The App Prints message.
Run Other.
Await Other.
Define "result" as Worker's Output.
Show result.
Show `finished`.
Create "Other" as a New Public Basic App.
The App Prints otherMessage.
Show Other's Output.
Run Worker.
Await Worker.
Show `done`.

Complete program. Source: demo/paragraphs/run-within-paragraph.l.

Example evidence

Continuation launches and awaits another App. existing-witness-not-run. Evidence guide.

A continuation can Run/Await another target, but cannot rerun its own active target. Inline ordering produces Other\nInner\nfinisheddone.

Normal program completion and bare Exit clean up owned processes without running unawaited continuations. See the execution reference for failure, signal and cleanup rules.

Lifecycle operations require an App. This example is rejected before execution:

testdata/phase1/n01-await-text/main.l
Use IO's Print from `io` as "Print".
Await `not an App`.

Expected compilation failure. Source: testdata/phase1/n01-await-text/main.l.

Example evidence

Compiler rejects Text as the operand of Await. existing-witness-not-run. Evidence guide.

Text cannot be Awaited. The compiler reports TypeMismatch and publishes no new executable.


Canonical source: docs/guide/lifecycle.md.