Go · Design

Design

4.0.0-rc.1 · c58749fe

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/uform/go/design.md' | claude -p "How would this fit my code?"
  • 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.
PathGoRust
Blocking call1 frame0
Refusal before the call1 Error1 error
Deferred submit and wait4: frame, Deferred, 2 in AddCleanup0
Each callback1 handle0