On this page
Arrays, records, aggregates, and abstractions
Composite values contain other values. Their type, bounds, active variants, visibility, and ownership determine which operations are legal. A familiar collection literal does not make two independently declared types interchangeable.
Arrays and bounds
An array type defines one or more discrete index domains and a component subtype. Constrained array types have fixed bounds; unconstrained types receive bounds for each object or value. Bounds are part of the value's shape, not a universal language-wide origin. Use attributes or the source presentation's shape facilities rather than assuming every array starts at zero or one.
These are Vada declaration fragments:
type Fixed is array (1 .. 4) of Integer;
type Values is array (Positive range <>) of Integer;
A : Values (3 .. 5) := (10, 20, 30);A contains three elements at indices 3, 4, and 5. Reading or writing an element requires an index within the corresponding bounds; B4103 identifies a failed index obligation. A constant array value does not make every variable index provably safe.
An unconstrained array object needs explicit bounds or a supported initializing value that determines them. A subtype with unspecified bounds is indefinite and cannot supply storage for an arbitrary uninitialized local. An unconstrained parameter/result can carry bounds with its value. Constrained destinations must have compatible lengths.
Whole-array assignment uses positional correspondence: equal lengths may permit values whose lower bounds differ to slide to the destination's bounds. Sliding is not arbitrary reshaping. Each dimension must have the required length, and components must have compatible types. A length mismatch is B4106. Assigning a slice must satisfy its target length and element constraints as well as the slice's own bound rules.
Null arrays have an empty index range and zero length. Iteration over them visits no components. Their bound values can still be observed; do not identify every null array with the same pair of numeric bounds.
Multidimensional arrays
A multidimensional array has a fixed rank, with bounds for each dimension. Unconstrained dimensions receive bounds at construction or a call boundary. Values must be rectangular: a matrix is not a ragged list of unrelated rows. The native representation is contiguous component storage with the bounds needed to interpret dynamic shapes.
type Matrix is array (Positive range <>, Positive range <>) of Integer;
M : Matrix (2 .. 3, 7 .. 9) := (others => (others => 0));The first dimension has length 2 and the second length 3. M(2,7) selects one scalar component. Vada/Varc dimension arguments to bound attributes start at 1; Vibe's shape and dimension properties use their documented zero-based presentation. Rank/shape declarations and source index origins are separate decisions in Vibe.
Component iteration over a matrix uses row-major order: the last dimension varies fastest. Explicit nested index loops can express another traversal order. Matching operations on two matrices requires the appropriate dimensional lengths and index correspondence; a mathematical “square” condition alone does not imply identical lower bounds.
Embedded APL text operates on these arrays, including matrix products and the rank operator.
Aggregates and updates
An aggregate constructs a composite value. Its expected type comes from context or an explicit qualification/construction form. Without enough context, Verada cannot determine which array, record, or container is intended. Parentheses or brackets alone do not erase nominal type identity.
| Form | Meaning and obligations |
|---|---|
| Positional components | Values correspond to component/index positions in order |
| Named associations | A field, index, range, or choice identifies the supplied components |
others |
Covers remaining components where that aggregate form permits it |
Default box <> |
Uses the applicable component default; it requires such a default (B2010), where Ada leaves a component without one default-initialized |
| Iterated association | Produces elements from a supported iterator, with optional filters |
| Delta/update aggregate | Starts from an existing value and changes identified components |
| Extension aggregate | Supplies an ancestor part plus the new components of a tagged extension; an ancestor given as a subtype mark, (Parent with ...), gives the parent's components their defaults, so each needs one (B2010) |
All required record fields and array positions must be covered exactly as the accepted form requires. Overlapping named choices, a missing component, or incompatible bounds are errors rather than unspecified defaults. Runtime-bounded named aggregates and supported iterated others forms generate coverage and bound obligations.
An iterated aggregate can evaluate a map expression once per accepted source element. Filters change the number of constructed elements. The destination must have sufficient capacity or the correct inferred shape. A source iteration's range does not automatically prove an unrelated fixed-length target is exactly filled.
A delta aggregate creates an updated value. Ordinary assignment through a record field or array component changes an existing object and has different aliasing and lifetime consequences. Limited or owning components can restrict both construction and copying. Vibe does not have a direct spelling for every Vada aggregate/update form.
Records and discriminants
A record groups named components, each with a type and optional default initialization. Component selection requires a visible field. Private representations cannot be accessed by treating their values as structurally equivalent public records.
Discriminants are parameters describing a record's shape or variant. A variant part makes some components present only for certain discriminant values. Selecting a conditional component requires proof that it is present; this is a discriminant check, B4107. A branch on the discriminant can establish that fact. Updating other fields does not itself prove which variant is active.
Constructors/aggregates must supply discriminants and active fields consistently. Unknown or defaulted discriminants affect whether a type is definite and how objects are constrained. Access discriminants are excluded from the supported ownership language. Vibe dataclass unions provide selected variant-like forms rather than every Ada discriminant construction.
A private type may declare unknown discriminants, (<>), and be completed by a record with discriminants of its own: clients then make its values only through the package, each object from an initial value. A private or incomplete type with known discriminants is completed by a record that repeats them. A derived type may declare discriminants of its own that constrain its parent's (in any order, one of them two of the parent's, the others given values), and a type extension may declare discriminants of its own after its parent's components. Their discriminant checks are proved as a record's are (Vada's rules).
Initialization and equality
An aggregate initializes the components it actually supplies. Record defaults initialize their components; access defaults are null. A scalar type with Default_Value, and an array type with Default_Component_Value, give objects, components and allocators made without a value that value (see aspects); <> in an aggregate gives it too. Other scalar declarations without defaults are not automatically valid arbitrary values available for reading. Flow analysis checks each required initialized part. Arrays can be filled component by component, but a whole-array read or call requires the appropriate initialized components.
Structural equality compares the applicable components of supported composite values. Variant records compare the active shape and components; inactive fields are not ordinary values to read. Tagged/class-wide values include the relevant dynamic type behavior. User-defined equality can instead be a visible operation with its own contract. Do not equate equality with equal allocation addresses or hidden storage handles.
Strings and copyable text
String is an unconstrained array of Latin-1 Character, normally indexed from a positive bound. For Unicode text, Wide_Wide_String is an array of Wide_Wide_Character, one code point a character, and Wide_String the same for the Basic Multilingual Plane. A string literal takes its type from its context, so "café ☕" is a Wide_Wide_String where one is expected and an error (B0005) where a String is. Ada.Strings.UTF_Encoding.Wide_Wide_Strings converts between code points and UTF-8 (Encode, Decode; Decode reads a malformed byte sequence as U+FFFD, the replacement character), and Ada.Wide_Wide_Text_IO prints wide text as UTF-8. Its length and lower bound are observable. Concatenation creates the appropriate array value and requires representable bounds/lengths. Assignment to a constrained string requires matching length; it is not an implicit growable-string operation.
Verada.Strings.Texts.Text is a private copyable value with immutable character storage. Its model is the String returned by To_String. Copies may share that storage internally, and the final holder releases it. Copying a text does not allow one copy to mutate the other. To_Text, To_String, Length, Element, equality, and concatenation connect the two representations. Vibe str uses Text; Varc chooses text for a literal when the expected context requests it, while Vada/Varc String remains available.
Bounded strings, limited unbounded strings, and copyable text have distinct capacity, assignment, and resource properties. The string libraries supply their contracts; a Python string method is a library operation. See the Vibe reference for images and f-strings.
Containers and iteration protocols
Containers are typed library instances, not a second untyped array system. Their operation preconditions describe capacity, valid positions, and permitted updates. Formal bounded containers, unbounded reclaimed containers, functional proof models, and arenas serve different purposes. The vector guide is a complete example.
The Iterable aspect identifies first/next/has-element/element operations for supported container iteration. Cursors are protocol values; they are not necessarily numeric array indices. The Aggregate aspect identifies empty/element-add operations for supported container aggregate construction. Merely accepting either name does not make arbitrary combinations of operation profiles legal or establish their termination.
A loop or quantifier must obey the container's public iteration and mutation contract. Element views can restrict mutation of the container while a view is live. Do not infer cursor stability, insertion order, immediate element destruction, or deallocation from generic container vocabulary; those are API properties.
Tagged types, class-wide values, and interfaces
A tagged type has a runtime type identity and primitive operations. A derived extension contains its parent's components plus its own, and may implement supported interfaces. An abstract type/operation requires a concrete implementation before an object can be used as a concrete instance. An overriding declaration must match the inherited profile.
A class-wide value can hold a permitted member of a hierarchy. Dispatch selects an operation using the dynamic tag. Converting down to a specific type requires the relevant tag check, B4110; membership tests can establish a suitable branch condition. See subprograms for dispatching calls.
Plain and limited interfaces describe supported abstract operation sets; synchronized, task, and protected interfaces are excluded. Vibe maps supported ABC, dataclass hierarchies, and Protocol forms into selected parts of this system. Arbitrary Python inheritance, properties, or special methods are not implied.
Private tagged views preserve abstraction. Clients reason from visible contracts; representation invariants are maintained at the specified boundaries, not necessarily after every internal assignment. Class-wide pre/postconditions support substitutability and are distinct from ordinary specific contracts. See contracts.