Keywords
How each of Program's keywords is rendered into Go.
Contents
How a Program becomes Go, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.
- Introduction — what the Go target is, and how to read the rest of this section.
- Capabilities — which high-level features are possible, built in or through a library.
- Example — a full program using every keyword, and the Go it renders to.
- Naming considerations — how Program's dotted names are carried into Go.
- Entry point — starting a program from
mainwith its drivers. - Drivers — the native drivers that provide the interface, console and network.
- Runtime — the Reactive and Context machinery the rendered code links against.
- Native modules — the hand-written Go behind
NATIVEfunctions. - Keywords — how each of Program's keywords renders to Go.
- Project setup — the files and commands to build and run the rendered program.
- Reserved words — the words Go keeps for itself, and how a colliding name is escaped.
Program keywords in Go
Each of Program's keywords maps to idiomatic Go. Names join with an underscore into one “static” struct (see the example); the reactive keywords are calls into the runtime. Follow a keyword's own page for the full rendering and the other targets.
| Keyword | Rendered Go |
|---|---|
MODULE | A lowercase Go package, with names underscore-joined into a static struct — Ui.Button.Integer becomes Ui_Button_Integer. |
TYPE | A record becomes type Point struct { x float64; y float64 }; a union becomes a struct with a tag and one optional field per option. |
FUNCTION | A method on the static struct: func (S) Name(…) T { … }. |
NATIVE | A method whose body is the go NATIVE string. |
INPUT | A parameter; a BINDING input is read and written. |
HOLE | A trailing func() callback parameter. |
LET | name := …. |
STATE | name := Reactive.State[T](value). |
REVERSE | A write-back whose closing SET is Reactive.Set(state, value). |
WITH | Module_With(Name, Replacement, func() { … }). |
See JavaScript keywords for the per-keyword detail and the modifiers; Go differs in idiom (packages, underscore-joined static structs) but the mapping is the same.