REVERSE | Language | Program

A REVERSE is a write-back block describing what happens when a value is written.

The grammar of a single REVERSE line:

A REVERSE keyword can only live inside a FUNCTION keyword.

In a function body, a reverse pins a write-back rule to the value it names.

When something writes that value, the reverse runs — its forward body computes from the incoming value and the closing SET writes the result into outer state.

The indented lines of a REVERSE are its body, in order: a forward body, then a closing write-back.

Zero or more LET bindings (and effect calls) make up the body, computing from the incoming value exactly as in a forward block. They prepare the value that the closing SET writes back.

An effect call on its own line, doing work in the forward body before the closing write-back.

SET is the single point where a write actually takes effect, and it must be the final statement(s) of the block — never before the body is done, and never outside a REVERSE . It pushes a value into an outer STATE : it names the state to write and the value to put there, written SET stateName = value . It carries no body of its own and opens no further lines. Because it only ever ends a REVERSE , the renderer lowers it to the reactive setter Reactive.Set(state, value) ( Reactive::set in Rust, Reactive.set in Zig). Here a retry bumps a reload counter, the whole block ending in its SET :

The same example, rendered to each target; the closing SET becomes the reactive setter on the last line of each block.

A two-way parameter is an INPUT in BINDING mode, usually targeting a STATE — the same STATE a reverse's closing SET writes into. Bodies are built from LET bindings, and reversibility is explored in Context . Back to the language .

Recommended articles