Targets · Zig · Keywords

Keywords

How each of Program's keywords is rendered into Zig.

Contents

How a Program becomes Zig, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

Program keywords in Zig

Each of Program's keywords maps to Zig. Names nest through struct containers joined with . (see the example); because Zig has no closures, a callback becomes a named struct function. Follow a keyword's own page for the full rendering and the other targets.

KeywordRendered Zig
MODULEA nested struct container, snake_case — Ui.Button.Integer becomes ui.button.integer.
TYPEA record becomes pub const Point = struct { x: f64, y: f64 };; a union becomes pub const Shape = union(enum) { circle: Circle, rect: Rect };.
FUNCTIONpub fn Name(…) ReactiveValue(T) { … }.
NATIVEA pub fn whose body is the zig NATIVE string.
INPUTA parameter; a BINDING input is read and written.
HOLEA named struct { pub fn run(…) … }.run callback (Zig has no closures).
LETconst name = …;.
STATEconst name = Reactive.state(T, value);.
REVERSEA write-back whose closing SET is Reactive.set(state, value).
WITHmodule.with(name, replacement, struct { pub fn run() … }.run).

See JavaScript keywords for the per-keyword detail and the modifiers; Zig differs in idiom (struct containers, struct-function callbacks) but the mapping is the same.