DEVELOPMENT EDITION · 769442725406
Language Reference
On this page

Expressions, operators, and evaluation

An expression computes a value of a type. Expected type context participates in resolving literals, overloaded names, operators, function results, and aggregates. A well-typed expression can still generate proof obligations for overflow, bounds, nullity, predicates, or contracts of called functions.

Names and primary values

Expressions include literals, object names, selected components, indexing, slices, function calls, conversions/qualifications, aggregates, and attributes. A name can denote an object, type, package, subprogram, enumeration literal, or generic. Context determines which categories are legal at that point; a package or a type is not an ordinary runtime value just because its name parsed.

A parameterless function may use a name form in Vada; Varc/Vibe use their accepted call forms. Distinguish an operation returning an array from indexing an existing array. Varc requires calls/conversions with parentheses and indices with brackets, reporting B0705 or B0706 for the wrong convention. Vada uses parentheses for both and resolves the denotation.

Operator families

Operation Shared meaning Syntax notes
+, -, multiplication Typed arithmetic Signed bounds and fixed/floating rules apply
Division/remainder Domain-specific quotient/remainder Vada/Varc integer / truncates; Vibe / is true division and // floor division
Exponentiation Typed power with operand and bound obligations Spellings and associativity are frontend-specific
Equality/order Compare compatible values Boolean is distinct from integer; composite ordering is limited to supported types
Boolean logical operations Compute Boolean results Short-circuit forms have distinct evaluation behavior
Modular bitwise operations Work on supported modular/bit domains Do not substitute for Boolean short circuiting
Concatenation Construct the supported sequence/text result Vada &, Varc ++, selected Vibe text/list forms
Membership Test ranges, choices, subtypes, tags, or supported containers The operand and domain must have compatible meanings

The exact precedence, associativity, non-associative groups, and mandatory parentheses belong to each syntax reference. They are not interchangeable across frontends. In particular Vada -7 mod 3 groups as -(7 mod 3), while (-7) mod 3 is 2. Varc deliberately rejects some unclear mixes of operator groups. Vibe comparison chaining has Python-shaped semantics, rather than repeated binary comparisons with Boolean-to-integer conversion.

In Vada an operator is also a function named by its symbol, its letters in any case ("and" and "AND" are one operator): function "+" (L, R : Money) return Money declares one, and a call may name it in prefix notation, "=" (A, B) or "-" (Right => D, Left => C), which means A = B and C - D.

See integer ranges for signed division, floor division, and mod/rem. Types defines numeric result domains.

Evaluation and short circuiting

Ordinary supported function expressions must obey the function/effect rules. A function cannot acquire unrestricted effects by appearing in an operator or a pipeline. Vibe's supported mutation-and-result operations are lowered through explicit procedure/result forms and are restricted to their accepted contexts.

For a short-circuit conjunction, the second operand is evaluated only if the first is true. For a short-circuit disjunction, it is evaluated only if the first is false. Proof of the second operand uses that path condition. This makes a guard such as “index in range and then element at index has the desired value” meaningful: the index expression is not evaluated on the failing guard path.

Non-short-circuit Boolean operations evaluate their operands and require both to be safe. Do not replace Vada and then by and merely because both give the same Boolean truth table. Likewise, Vibe and/or in the supported subset combine Boolean expressions; they do not implement arbitrary Python truthy operand selection.

Operands and call actuals are evaluated in a defined order, but a program cannot depend on it: functions in expressions have no side effects, and volatile reads and aliasing are restricted. Make effectful work explicit in statements, and preserve its order when translating source. In particular, foreign code declared with an inaccurate pure contract lies outside the proof guarantee.

Membership and discriminating branches

A range membership checks whether a value falls between compatible bounds. A subtype membership also considers the accepted subtype conditions. Tag/class membership identifies applicable members of a hierarchy. A container membership operation uses its supported library mapping, not an arbitrary search protocol on any object.

Use membership to establish facts for a branch: bounds for subsequent indexing, active variants, or permitted dynamic tags. A membership expression is a Boolean value, not a conversion or an assertion that changes storage. A subsequent write or asynchronous input can invalidate a previously observed relationship.

Conditional and case values

A conditional expression chooses the value of one branch. The selected branch is evaluated under its condition; unselected alternatives are not evaluated merely to compute the result. All alternatives must meet the expected type rules. A value-producing conditional requires the necessary alternative coverage rather than silently returning an undefined value.

A case/match expression selects a value using compatible, non-overlapping choices, with complete coverage as required. Ranges and an others alternative can supply coverage in the accepted forms. Statement case/match executes statements instead and is described in statements. Vibe class patterns have specific supported binding forms; this is not arbitrary Python pattern matching with guards.

Quantified expressions

A universal quantifier is true when its predicate holds for every visited value. An existential quantifier is true when at least one visited value satisfies it. On an empty domain, universal is true and existential is false. Supported domains include discrete ranges, arrays, and containers with the required iteration protocol. A filter restricts which source values are considered.

Vada uses (for all ... => ...) and (for some ... => ...); Varc uses its forall/exists forms; Vibe recognizes supported all(...)/any(...) generator forms. Generators in these positions do not become independently storable lazy values.

Predicates must be safe and obey purity. Calls in predicates are interpreted using their contracts and supported expression semantics. An infinite or extremely large runtime quantifier is not a free substitute for proof: ghost-only/non-executable contracts can be unavailable for runtime enforcement, and resource costs remain relevant.

Declaration expressions

Vada supports the accepted declaration-expression form that introduces constant objects or renamings for a following expression. Each name is scoped to that expression. A declaration expression is useful for naming an intermediate calculation once; it does not permit arbitrary procedures, mutable statement sequences, or hidden side effects.

The following is a fragment illustrating the structure:

(declare Half : constant Integer := N / 2; begin Half + Half)

It needs a visible integer N and the applicable arithmetic checks. Varc writes the same as a braced expression, { let half: Integer = n / 2; half + half }. Vibe has no declaration expression; use ordinary statements.

Raise expressions and attributes

A raise expression transfers control by propagating a declared exception rather than producing an ordinary value. Its use is constrained by exception legality and contracts; it does not turn a function into an unrestricted exception-producing operation. See exceptions for the required propagation policy.

An attribute asks for a property of a type or object, snapshots a value at a defined point, or performs a supported typed operation. The complete attribute catalog states valid prefixes, arguments, and special contexts. In particular Old, Result, Loop_Entry, Range, Access, and Address have special legality rules; they are not arbitrary member lookups.

Lambdas and consumed pipelines

Supported inline lambdas serve particular frontend forms such as pipeline stages. They are not general closure values that can capture mutable environments, escape, and execute later. A pipeline requires its consumer in the same expression; its intermediate chain cannot be assigned or passed as an ordinary value. The pipeline reference defines stage order, early termination, and proof behavior.