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.
Choose the operation by its effect
Section titled “Choose the operation by its effect”| Form | Effect |
|---|---|
| Build | Check an already compiled companion; no runtime compilation |
| Run | Start an App without waiting for completion |
| Stop | Request forceful termination without waiting for completion |
| Await | Join the finalized result; activate its continuation once |
| Start | Source-defined Build then Run |
| Execute | Source-defined Start then Await |
| Output | Read finalized raw stdout without waiting |
| Error | Inspect 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.
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 and errors are different streams
Section titled “Output and errors are different streams”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:
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.
Nested work belongs to the continuation
Section titled “Nested work belongs to the continuation”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.
Termination and cleanup
Section titled “Termination and cleanup”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:
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.