On this page
Arenas and optional values
These families address two different forms of indirection: a validated handle into bounded shared storage, and a value that is either present or absent. Neither is an unchecked pointer.
Generational arenas
Verada.Containers.Arenas takes an element type and positive Capacity. Handle is a nonnegative Long_Long_Integer, with zero No_Handle. An Arena begins with no valid handles. Valid(A,H) establishes that H denotes a currently live slot/generation in that arena; Element requires it. Has_Room is the insertion guard, not an assumed arithmetic formula involving an API Length function (there is no such public operation).
Insert requires Has_Room, returns a new valid handle through an out parameter, stores Item, and preserves every other valid handle/value. Replace_Element requires validity, changes only that element and preserves validity/room. Remove requires validity, invalidates that handle and preserves other live elements. Replacing/removing through the wrong arena is not meaningful even if the same numeric handle happens to be valid there.
The generation count prevents an old removed handle from referring to a reused slot in the same ongoing arena history. Generation space is finite: an exhausted slot is retired. Thus free physical slots do not imply Has_Room. The representation computes a slot and generation from a nonzero integer; clients should not fabricate handles or depend on its arithmetic. Copying an Arena copies its state. A handle carries no identity of its arena: use it only with the arena whose Valid you proved.
Models is a Functional.Maps instance over Handle and Element_Type. Model is ghost and relates its keys to exactly valid handles and its paired elements to Element. A quantified expression over all handles belongs in contracts and ghost code; it is not executed. Slots are stored inside the arena, finding room scans the capacity, and Remove does not overwrite the slot. For cyclic graph updates, rely on the contracts that say which handles stay valid.
Vada: package Nodes is new Verada.Containers.Arenas(Integer, 8);. Varc: package Nodes = new Verada.Containers.Arenas<Integer, 8>;, with & on changed arena/output actuals. Vibe does not instantiate library generics: wrap the arena in a Vada or Varc package that exports the operations a Vibe module needs.
Optional values
Verada.Optionals takes an element type. Optional is a discriminated record with Present defaulting false; Item exists only in the true variant. None returns absence, Just(X) constructs presence, Has_Value tests it, and Value requires presence. Reading O.Item without establishing the discriminant is a separate discriminant check.
Keep_First(So_Far,Next) retains an existing present accumulator, otherwise takes Next. Keep_Last takes Next when it is present, otherwise retains So_Far. They combine optional values; they do not themselves stop source iteration or execute a search. An empty reduction can keep None. Side effects and early termination belong to the pipeline language operation.
Vada can instantiate package Maybe is new Verada.Optionals(Integer);. Varc uses package Maybe = new Verada.Optionals<Integer>;. Vibe's Owned[T] | None annotation is a different mechanism (an owning access value that may be null), not an instance of this generic.
An Optional is an ordinary discriminated record: it allocates nothing to express absence, and copying or comparing one copies or compares its element.