Files
aji/docs/reference/type-properties.md
T
dev 4138a52af6 cli: add initialized buffers and safe owning vectors
Introduce linear_buffers through the specification, AIR parser/serializer,
verifier, deterministic interpreter and source lowering. A buffer owns an
initialized prefix with explicit reserve, bounded push, moving pop/views and
recoverable empty-only free. Growth charges old+new capacity; failed growth,
full push and nonempty free preserve or return complete ownership.

Implement compiler-pinned safe std.vec with nine operations for Copy values,
owners, files and channel endpoints. Permit complete Copy moves inside
specialized generic bodies without weakening monomorphic or borrow rules.
Update RFC 0024, Q-036, STD-6a/b, reference grammar, Quick Reference, bundles,
source coverage and CI. Remaining collections stay STD-6c.

Validation: unit tests and AIR round-trip; 757 conformance cases; 56 dedicated
buffer cases with per-instruction collection and 32-seed schedule stress;
extended memory test; hosted smoke; 36 module, 20 generic, 49 linear and
118 buffer CLI checks; 91/91 source constructs; Zig fmt and reference bundles.
Full source bundle: 49,589 -> 52,384 cl100k tokens (+5.6%); AIR 175,736 bytes.
The reference interpreter's push copies its initialized prefix; no native
performance or empirical MCC benefit is claimed.
2026-10-06 23:26:41 +03:00

3.3 KiB

Type Properties

Aji 0.1 uses compiler-known structural properties rather than a user-defined trait system.

Copy

A Copy value may be duplicated without changing ownership semantics.

Typical examples: integers, booleans, small aggregates containing only Copy fields.

Not Copy: Own<T>, Region, Island<T>, atomic<T>, File, Socket, task/thread handles.

Send

A Send value may move to another concurrent execution context.

A type becomes non-Send if it contains thread-affine/local state.

Share

A Share value may be observed concurrently through immutable access.

Deeply immutable values are normally Share.

Interior-mutability wrappers must establish their own synchronization semantics to qualify. mutex<T> does so by locking. atomic<T> does so because every access through a shared borrow is an atomic operation with an explicit ordering (spec 04 §23).

Freeze

A Freeze type may participate in deep immutable conversion.

External resources that remain operational/mutable may prevent Freeze.

Local

A Local value is tied to its current execution context and prevents migration/transfer.

Examples may include thread-local handles, event-loop-local registrations or platform UI objects.

IslandSafe

An IslandSafe value may be stored in an island graph (spec 03 §22). Derived structurally:

  • IslandSafe: integers, bool, built-in enums, iref<U>, and arrays, structs and enums of IslandSafe values.
  • Not IslandSafe: borrows, owners, regions, graph owners (island, frozen, arc), resources, endpoints, task, scope, shield, guard, mutex, atomic<T>, cap<K>.

Because of it, a graph never holds outside authority or a mutable ownership edge, so freeze, conversion and transfer are O(1).

ArcSafe

An ArcSafe value may be held by an arc (spec 03 §24): the last release destroys it by freeing memory only, with no user or resource action. In format 0 it is exactly IslandSafe. Share alone is not enough; for example, a mutex<T> is Share but not ArcSafe.

Format-0 source constraints

Spec 15 §15 fixes the exact property queries used by explicit generic specialization. Copy includes integers, booleans, built-in enums, capabilities, iref and aggregates of Copy members; borrows and linear values are excluded. Send/Share use spec 04 §35. Freeze currently equals IslandSafe plain graph content; it does not promise conversion of arbitrary owners or resources. Local has task/scope/shield/guard/internal-storage base cases and propagates through borrow/own/own_array/buffer/mutex wrappers and arrays/aggregates containing Local content. It is not the complement of Send. These properties add no methods, effects, unsafe declarations or implicit resource actions.

Under linear_aggregates (spec 03 §25), structs/enums/fixed arrays containing any linear member are linear as whole values. Every variant contributes, regardless of the active tag. Borrow/storage/function-bound members remain forbidden; whole-value unpack/take/exchange preserve exactly-once consumption.

Under linear_buffers (spec 03 §26), buffer is always linear; Send/Share follow T, and Local propagates. Borrow/storage/task-bound content is forbidden. It is neither IslandSafe nor ArcSafe: its nested linear values require explicit draining.