# Design

> UForm's design from Go

4.0.0-rc.1 · c58749fe

- **A thin layer over the C ABI.** One file per header, `types.go`, `model.go`, `encode.go` and `train.go`; every name is its C name without `uform_` and `_t` in PascalCase, a verb’s argument struct becomes its `*Config`, and every wrapper’s documentation names the C symbol it calls or says it is binding-only.
- **The receiver chooses, the verb stays.** The model runs a verb on the calling goroutine, `On(executor)` blocks on an executor, and `Deferred(executor)` submits it, all with the same arguments.
- **Deferred calls use the language’s own idioms.** `Status` polls through `uform_outcome_status` and `Wait` blocks through `uform_outcome_wait`, and refusals answer before anything is submitted.
- **No life of its own.** The binding starts no goroutines and keeps no queues, locks or counts; releasing a `Deferred` rides `Close`, which waits for the call first, or the collector’s cleanup, which frees it only once final.
- **Arenas belong to the caller and are reused, never shared.** Every output whose length scales with the call lands in an arena the caller passes, and its views end at the arena’s next call.
- **One pinned frame per call.** A call’s outcome, argument struct, callback handles and result share one allocation holding no unpinned Go pointer, since cgo pins only heap objects.
- **Suites run against the stub library**, and `TestCallsAllocateOnlyTheirFrames` pins the budgets below.

| Path | Go | Rust |
| - | - | - |
| Blocking call | 1 frame | 0 |
| Refusal before the call | 1 `Error` | 1 error |
| Deferred submit and wait | 4: frame, `Deferred`, 2 in `AddCleanup` | 0 |
| Each callback | 1 handle | 0 |
