Date: 2026-06-16
Accepting or returning a record across the boundary needs a known memory layout.
Clojure records participate through defrecordz, not automatic
conversion of arbitrary records.
A bridged record gives Zig a known field order, field types, alignment, layout, and ownership rules; an arbitrary Clojure record carries none of these.
Automatic record-to-struct conversion was considered; without a declared layout it cannot produce a sound Zig struct.
The record bridge now carries buffer and :string fields in addition to
scalars and enums. A field may be [:bytes [:slice :u8]] (to a byte[]),
[:owned [:slice T]] or [:slice T] (to a vector), or :string (an owned
UTF-8 buffer marshalled to a String). Each buffer field lowers to a
usize pointer and a usize length in the wire extern struct, since a
Zig slice is not a C type, so a record can model a multi-value result. The
ownership and free protocol for those fields is ADR 21; the bridge itself
stays explicit through defrecordz and deftypez.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |