Context
Share a value down the tree without passing it by hand. Context lets a scope publish a value under a name, and anything running deeper in the call tree can read it — no extra input threaded through every function in between. Because the published value is reactive, readers stay live: when it changes, everything that read it recomputes.
Context is the quiet machinery behind several everyday features rather than something you usually reach for directly. It is how a group of options knows which one is selected, how emitted items are collected into a channel, and how ambient values — a theme, a locale, the current interface slot — reach the code that needs them.
How it is used
Grouped selection
A selection group publishes the chosen value over a block, and each option reads it back to decide
whether it is the active one — the pattern behind
Maths.Integer.Select and
Logic.Select. The value is set once, at the top of the block,
and read by every option nested inside it.
STATE Maths.Integer choice = 2
Maths.Integer.Select choice
Maths.Integer.Option 1
Ui.Content.Text "One"
Maths.Integer.Option 2
Ui.Content.Text "Two"
Collected channels
Some calls emit into a named channel that a driver drains at the end of the cycle rather than
returning a value. Console.Line works this way:
each call appends its text to the console channel, and the console
driver prints whatever accumulated.
Console.Line "first"
Console.Line "second"
How it works
Context is a native module: it is implemented directly in each target rather than in Program, because it reaches under the reactive runtime to keep a small, scoped stack of published values keyed by name. A value is pushed when a block opens and popped when it closes, so a name resolves to the nearest enclosing publisher and never leaks past its block. Reads are tracked like any other reactive dependency, so a reader recomputes when the value it took from context changes.
Everything here happens beneath the surface of the modules that use it — you write
Select/Option or Console.Line, and context carries the value
or the channel between them. It is documented as its own module because it is the shared foundation
those features are built on, and understanding it explains why they compose the way they do.