On this page
Varc statements and advanced features
A braced body contains declarations and statements. A declaration after a statement opens a nested scope extending to the body's closing brace; use explicit braces when the intended lifetime should end earlier. An empty body {} has no action. A standalone ; is also an empty statement.
Assignment and calls
count = count + 1;
increment(&count);
count += 2;
Assignments require writable, compatible targets and establish required subtype/predicate checks. The compound forms are += -= *= /= %= &= |= ^=. %= means remainder assignment, not modulus assignment. ++ concatenates values; count++; and count--; are rejected.
Compound assignment uses the supported target-name semantics, also spelled @ in a suitable assignment expression. It does not create C-style expression-valued assignment inside conditions. Use == for equality and != for inequality.
A procedure call can be written reset();. A no-argument name can also be recognized as a call, but explicit parentheses are clearer in Varc. Mutable actuals require &. A function result does not become an ignored statement value merely because the source ends in ;.
If and match statements
if value < low {
value = low;
} else if value > high {
value = high;
} else {
;
}
Braces are required; parentheses around a Boolean condition are optional. else if is two words, not elsif. A declaration inside a branch is scoped to that branch's body.
An if can first bind names for its condition and branches, as Go and C++ write it: if let n = count(xs); n > 0 { ... } else { ... }; the names are constants, visible in the branches, an else if after it too. if let v = o { ... } else { ... }, with no condition after the binding, unwraps an optional: the first block runs with v the value when o has one.
A match has non-fallthrough arms:
match state {
Idle | Done => { count = 0; },
Busy => { count += 1; },
}
Arm choices can be supported values/ranges or a wildcard _/others, with coverage and overlap checks. Statement arms contain braces, while expression arms yield expressions. There is no C-style switch or implicit fallthrough.
An arm can have a guard, pattern if condition =>, as Rust writes it; the arms are tried in order. A match with guards ends with an unguarded _, or its unguarded arms cover every value between them, as a match without guards does:
match n {
0 => { put("zero"); }
1..=9 if n % 2 == 1 => { put("small odd"); }
1..=9 => { put("small even"); }
Integer::First..=-1 => { put("negative"); }
10..=Integer::Last => { put("large"); }
}
Each unguarded arm first tries the guarded arms before it whose choices it shares.
println(a, b) and print(a) write values' images; see printing. with x { ... } calls enter(&x) and exit(&x) around a block; see the with statement.
Loops, filters and exit
while remaining > 0 {
remaining -= 1;
}
for i in 1...limit {
visit(i);
}
for x in values when x > 0 {
visit(x);
}
loop {
advance();
break when finished;
}
These are body fragments. A for parameter is introduced by the loop. The in domain can be a discrete range/subtype or an array/container; the compiler resolves which it is. Both 1...limit and 1..=limit include limit. Use 1..<limit to stop before it. reverse follows in. An explicit element subtype can follow the parameter: for x: Item in values { ... }.
A filter uses when and skips rejected candidates. The optional while iterator clause stops on the first retained candidate that fails its condition, rather than behaving as another filter. Multiple sources can advance in step:
for i in 0..=100, x in values when x > 0 while x < limit {
visit(i, x);
}
Each source has its own bounds/cursor. Iteration ends when a source runs out.
A loop can walk a chain without a consumer, and name a tuple's items, or the values of an enumerate() or a zip(...):
for x in a.filter(x => x > 4) { visit(x); }
for y in a.filter(x => x % 2 == 1).map(x => x * 10) { visit(y); }
for (i, r) in a.take(2).enumerate() { show(i, r); } // i counts from 0
for (x, y) in a.zip(b) { show(x, y); }
for k in (1..=20).filter(k => k % 7 == 0) { visit(k); }
for (key, value) in pairs { show(key, value); } // a list of tuples
Each element passes the stages in order: a filter skips it, a map gives the next value, a take_while ends the loop. The shared pipeline/iterator rules define candidate/filter/stop order. Unlike Vada, Varc does not need a permission pragma for its own iterator surface.
A loop/block name precedes ::
search: for i in values::Range {
if matches(values[i]) {
break search;
}
}
break; exits the innermost loop; break name; selects a named enclosing loop. continue; skips the rest of the innermost loop's body and goes on with its next iteration; continue name; does so for a named enclosing loop, from inside an inner one too. Each can add when condition. do ... while is excluded: write loop { ...; break when !condition; }.
for i in 1...n {
invariant total <= 10_000 * (i - 1);
if i % 2 == 0 {
continue;
}
continue when i == 7;
total += i * i;
}
A loop's invariants and variants come before its first continue, which would skip them.
A range can be walked in steps of a positive size, as Rust writes it:
for i in (1...10).step_by(3) { visit(i); } // 1, 4, 7, 10
for i in reverse (0..<17).step_by(4) { visit(i); } // 16, 12, 8, 4, 0
The values are the low bound and each step after it up to the high bound; reverse takes the same values from the last. The step is checked to be a Positive. An invariant that names the loop parameter reads it as the value of the current step.
Loop proof annotations are statements at their intended cut point:
invariant total <= limit;
decreases remaining;
@Loop_Variant(Increases => position);
Moving the annotation changes where it is evaluated. They are not arbitrary hints that allow an unestablished property to be assumed.
Blocks, returns and exception handling
Explicit braces create a nested statement block. return; exits a procedure; return expression; returns from a function and checks its result subtype/postcondition.
An extended return constructs the named result object:
return output: Result_Type = initial {
initialize_more(&output);
}
This is a context fragment using a compatible result type. Without a body it ends with ;. Supported aliased and annotation properties belong after the result declaration's head/value in their accepted positions. The result object is not a function-wide named return variable.
Exceptions use exception Bad_Input;, throw Bad_Input; and optionally throw Bad_Input with "message";. throw; reraises the currently handled exception.
try {
attempt();
} catch error: Bad_Input | Missing_Data {
report(error);
} catch {
recover_other_allowed_exception();
}
This is a handler-shape fragment assuming declared operations and exception types. try/catch are contextual words. The occurrence name is optional; an unqualified catch { ... } is the supported catch-all form. Handler blocks can have their own local declarations. A procedure lists the exceptions it may propagate with throws; see the shared exception rules.
A finally part, after the catch clauses or in their place, runs on every way out of the try: when it ends normally, when an exception leaves it (which is then raised again), and before a return, a break or a continue takes effect. A value returned is computed before the finally part runs:
fn checked(value: Integer) -> Integer {
try {
return value * 2;
} catch Bad_Input {
report_bad();
throw;
} finally {
log_done();
}
}
The finally part runs once on each way out, and itself does not return, break or continue (it would drop the exception it may run for): leave after the try statement instead.
A proof failure is not a user exception value. Catching check exceptions is restricted.
Assertions, ghost declarations and state annotations
assert condition; creates an assertion, optionally followed by , message (a String): the message is computed only when the assertion fails, in a build that keeps assertions, and the failure's report ends with it; computing it must be free of run-time errors where the assertion is false. assume condition; adds a trusted assumption. ghost before a supported object, type, subtype, subprogram or generic declaration marks it for proof use. @Ghost is the explicit annotation form.
@Name(arguments); is a statement/declaration pragma. Effect contracts use @Global and @Depends on a subprogram profile. Type invariants, predicates, default initialization conditions and refined/abstract state use the corresponding shared annotation names and supported aggregate shapes. The exact aspect/pragma catalog distinguishes implemented meaning from mere recognized names.
Ghost status does not permit writes that influence executable state contrary to ghost rules. Advisory/no-proof execution cannot run arbitrary mathematical predicates simply because they were written with ordinary-looking syntax.
Ownership and reclaimed values
A typical linked structure is declared:
type Node;
type Link = *Node;
type Node = struct {
value: Integer = 0,
next: Link,
}
Allocation new Node(value: 7, next: null) yields an owning access value. Assignment of an owner can move it; subsequent use of the moved-from path is restricted. Local observer/ borrower forms use supported anonymous access types such as *const Node and *Node. They do not allow arbitrary shared mutable aliasing.
ref renames an object rather than making a copy. An aliased object and ::Access operate under lifetime/ownership checks. A general access type *all T designates a declared aliased object under the general access rules. Unchecked access and access discriminants are excluded.
Explicit deallocation uses a suitable instance of Ada.Unchecked_Deallocation, and the actual passed to its mutable parameter is marked &. Reclaimed library values instead use their type's finalization mechanism. A custom reclaimed declaration uses the supported @Finalizable(Finalize => release, Relaxed_Finalization => True) shape. Copyable reclaimed types additionally require a compatible adjuster, expressed with Adjust => adjust in that association list.
Finalizers/adjusters cannot require a precondition. Copying a reclaimed value must preserve independent ownership; ordinary owned-access fields cannot simply be duplicated into a copyable resource. Permitted copy placement is not an observable counter contract. The complete ownership rules define normal/exceptional cleanup.
Task and protected syntax
Tasking words are contextual. At library-package scope, forms include:
task worker;
task type Worker(id: Positive);
task body worker {
loop { perform_work(); }
}
These are declaration-shape alternatives; a task type's body uses that type's name. Tasks have the supported Jorvik-style lifetime and synchronization restrictions. They are not async closures or ordinary invocations that return when the task ends.
Protected declarations use one operation per item and private on each component declaration:
protected type Counter(start: Natural) @Priority(10) {
fn add(n: Natural);
fn value() -> Natural;
entry wait_full(total_now: out Natural);
private var total: Natural = start;
}
A matching protected body Counter { ... } supplies operations. An entry body adds when condition before its brace: entry wait_full(...) when total >= goal { ... }. The function/procedure/entry categories and race/nonblocking/ceiling analyses are shared.
delay duration; and delay until time; express supported time waits. Verada.Tasking.Stop() supplies Verada's shutdown API. A protected operation cannot reach a potentially blocking call merely because its source body contains no explicit delay. Runtime/platform priority behavior is separate from accepted @Priority syntax.
Rendezvous/select/accept/abort/requeue/parallel constructs and synchronized interfaces are not supplied by these forms. See concurrency and devices.
External objects and representation
External objects use annotations, for example:
var reading: Integer @Volatile @Async_Writers;
Put the object at package scope when using an address. @Address(expression), @Import and supported ::Address forms describe external mapping; the address expression, object volatility and overlay target must meet restrictions. @Volatile_Function has whole-value and repeated-read rules.
An asynchronous read is not a stable pure value across two reads. Snapshot it once when the calculation needs a single observation. An address annotation does not prove hardware existence or any arbitrary foreign program's behavior. The shared reference supplies the exact accepted memory and effect model.
Pipelines
A method chain has a source, pure stages applied in the order written, and a consumer:
scores.filter(x => x >= mark).map(x => x + 1).sum()
scores.filter(x => x >= mark).count()
scores.map(x => x * 2).collect()
scores.filter(x => x > 0).reduce(operator+, 0)
These are expression fragments requiring compatible source/result types and arithmetic bounds. The stages are filter, map and take_while. A chain begins with a stage, zip, enumerate, or a slice take(n), skip(n), take_last(n), skip_last(n); its source is an array, a container or a range in parentheses, (1..=n).map(x => x * x).sum(); to reduce a whole array with no stage, write values::Reduce(operator+, 0). Stage order is significant: on [2, 1, 3], take_while(x => x > 1).filter(x => x != 1).sum() is 2 (the 1 stops the pipeline), while filter(x => x != 1).take_while(x => x > 1).sum() is 5. The order example runs the first. Consumers include sum, product, count, reduce(reducer, initial), collect, all(x => condition) and any(x => condition). sum uses an additive initial zero and product a multiplicative initial one. A floating-point sum adds in order, as a loop would (see pipelines).
zip and enumerate add sources before stages:
a.zip(b).map((x, y) => x * y).sum()
a.enumerate().filter((i, x) => i >= first).map(x => x).sum()
An enumerate chain counts from zero. Lambda parameters matching all sources name the counter, primary element and companion elements in the supported order. After a mapping stage, the mapped element is the single stream value. Use the exact source-arity rules; arbitrary tuple destructuring/closures are not inferred.
find_or(x => condition, default) is the first element for which the condition holds, or the default; position(x => condition) is that element's position from 0, a Natural? (null when none holds). find_or follows the source, its zipped sources and filters; position follows the source itself.
find(x => condition), first() and last() produce optional search results through a visible compatible Verada.Optionals instance. first/last follow a stage, as in a.filter(x => x > 0).first().
Pipes can mix ordinary calls before/after completed pipelines:
scores |> filter(x => x > 0) |> map(x => x * 2) |> sum()
value |> clamp(0, 100)
value |> clamp(0, _, 100)
The piped value is the first argument unless one _ selects another position. While stages are unconsumed, another stage or an appropriate consumer is required. An inline lambda passed to an arbitrary function is rejected (B0708); a chain without a consumer is B0707; an ordinary call interrupting it is B0709; repeated placeholders are B0710.
Vada-style reduction remains available as a::Reduce(operator+, 0) and the supported bracketed value-sequence forms. A failing accumulator proof can offer a loop expansion where the pipeline is the whole supported return/assignment/expression-function value. Explicit loops then allow invariants; they do not remove arithmetic obligations.
Complete contexts are in the Varc pipeline corpus.
Compact statement map
statement ::= assignment ";" | call ";" | ";"
| if-statement | match-statement | loop | block
| "break" [name] ["when" condition] ";"
| "continue" [name] ["when" condition] ";"
| "return" [expression] ";" | extended-return
| "throw" [exception] ["with" message] ";"
| "try" block {catch-clause} ["finally" block]
| "assert" expression ["," message] ";"
| "assume" expression ";" | "invariant" expression ";"
| "decreases" expression ";" | annotation-pragma
| "delay" ["until"] expression ";"
| "with" item {"," item} block
| ("println" | "print") "(" [expression {"," expression}] ")" ";"
loop ::= [name ":"] ("loop" | "while" condition | "for" iterator | "for" pattern "in" chain) block
pattern ::= name | "(" name {"," name} ")"
item ::= [name "="] expression
iterator ::= name [":" subtype] "in" ["reverse"] (domain | "(" range ")" ".step_by(" step ")") ...
arm ::= choices ["if" guard] "=>" (block | expression)
Structured blocks, deterministic value types, explicit effects and proof obligations remain the governing model across all these source forms.