On this page
Varc syntax reference
Varc presents Verada with braces, fn declarations, let/var bindings and explicit public interfaces. It shares Verada's types, proof rules and execution model. Braces do not make it C, and a familiar spelling does not import Rust's ownership types or Python's dynamic values.
The chapters define Varc syntax directly and link to shared semantic rules.
| Chapter | Contents |
|---|---|
| Lexical structure | Names, contextual words, literals, comments and every token |
| Expressions | Complete operator/grouping rules, calls, indexing, attributes, aggregates and value forms |
| Declarations and types | Bindings, inference, arrays, structs, discriminants, tagging, access types and representation forms |
| Units, subprograms and contracts | Package extraction, visibility, imports, functions, methods, generics and contracts |
| Statements and advanced features | Control flow, exceptions, ownership, tasks, devices and pipelines |
| Printing, texts, tuples, optionals and collections | println, interpolated strings, text operations, tuples, T?, List/Map/Set, shifts and with |
The shared Language Reference owns semantic rules common to all syntaxes. Use integer ranges for a complete example of bounded arithmetic and the first proof lesson for the compiler workflow.
A package in one file
package Counters {
pub fn next(value: Natural) -> Natural
requires value < Natural::Last
ensures result == value + 1
{
return value + 1;
}
}
This file is counters.va. pub exposes the function. Natural is a bounded integer subtype, requires constrains calls, and ensures describes the returned value. Natural::Last names a type attribute.
The compiler extracts the public specification and implementation from this one source. You do not write a second file merely to supply this body. A main can import the package and call Counters.next(41). The maintained equivalent is the bounded increment package.
Familiar forms with precise differences
| Write | Meaning |
|---|---|
let n: Natural = 0; |
Immutable binding |
var n: Natural = 0; |
Mutable binding |
n = n + 1; |
Assignment |
n == 1 |
Equality comparison |
f(&n) |
Pass a writable actual to out/inout |
a[i] |
Indexing, including subtype-bound checks |
a[i, j] |
Multidimensional indexing |
1...8 or 1..=8 |
Inclusive range from 1 through 8 |
1..<8 |
Half-open range from 1 through 7 |
a ++ b |
Concatenation, not increment |
x %% y |
Modulus; x % y is remainder |
T(value) |
Type conversion |
value as T |
Qualification: supply expected type, not an unchecked numeric cast |
old(value) |
Entry-state value in an appropriate contract |
T::Image(value) |
Attribute operation |
Varc uses the declared spelling of library names: Ada.Text_IO, Natural and True are not automatically replaced by C-family aliases. Inferred local types do not remove finite bounds or nominal type identity.
Scope and compatibility
Declarations can be interleaved with statements in a braced body. A declaration after a statement introduces a nested scope extending to that brace's end; it is not unrestricted hoisting or a reassignable dynamic name.
Ordinary struct values have value/copy semantics subject to limited/reclaimed/ownership rules. ref is an object renaming, not a general Rust reference lifetime constructor. *T names an access type in type context and *p dereferences in expression context. *all T is a general access type with the restrictions in ownership; there are no unchecked shared references.
A project may mix Varc, Vada and Vibe units, and veradic translate converts between them (see compatibility).
Support boundaries
Varc leaves out C-style switch and do ... while, closures that escape, unchecked shared access and task rendezvous. Some of these spellings are recognized only to give a targeted diagnostic with the Varc alternative. Embedded APL (apl"...") has its own chapter.
Executable syntax sample
The complete syntax-reference project includes a package generic and a main using enumeration/struct/array declarations, constrained subtypes, mutable and named actuals, contracts, a delta aggregate, quantification, reduction, a range loop and match statements.
From the repository root:
veradic prove --no-cache --project docs/manuals/examples/syntax-reference/varc/verada.toml
veradic run --project docs/manuals/examples/syntax-reference/varc/verada.tomlThe run prints:
syntax: 3
sum: 6
The source of Choosers shows a generic declared in a package. Fragments elsewhere in this reference need their surrounding declarations and contracts; the advanced ones link to complete programs.