On this page
Programs, units, names, and elaboration
A Verada program consists of library units and their dependencies. A package groups related declarations and can hide representation details behind a public interface. A subprogram is an operation: a function returns a value and a procedure performs statements. A library subprogram can also be the application's entry point.
Files and units
| Presentation | Source organization | Interface and implementation |
|---|---|---|
| Vada | .vads specification, .vadb body |
Separate units for a package interface and body |
| Varc | .va file |
Public package members form the extracted interface; implementation remains in the same file |
| Vibe | .vb module |
The module becomes a package; supported declarations are extracted into an interface and body |
The driver chooses the syntax by file extension; a file with any other extension is read as Vada.
Unit filenames follow the unit's lower-case name with dots replaced by dashes. A Vada package Ledger.Store uses ledger-store.vads and ledger-store.vadb; Varc uses ledger-store.va. Vibe starts with the Python module filename and import mapping; consult its module rules before treating arbitrary dotted Python packages as Ada child units. Defining the same unit twice is an error, even in different syntaxes.
A context/import clause makes a dependency available. The compiler loads needed package specifications, parent units, and generic bodies. Ordinary imported package bodies must also be selected explicitly or included by project source enumeration for an executable; finding a dependency specification does not automatically select its ordinary body. The selected dependency closure is checked, not merely one isolated file. A project source directory helps locate dependencies; it does not automatically make all their declarations directly visible.
Specifications and bodies
A specification states public declarations, types, profiles, and contracts. A body provides implementations and internal declarations. A body must conform to its declaration: parameter names/modes/types, result, and other profile requirements are checked. A missing required completion or an extra body is diagnosed. Expression functions, null procedures, and imported operations are examples whose required body form differs from an ordinary declaration.
The Vada fragment below declares an operation without showing its implementation:
package Counters is
procedure Advance (Count : in out Natural)
with Pre => Count < Natural'Last;
end Counters;Its declared contract is the public promise clients rely on. The prover also sees the bodies of expression functions and of local subprograms without contracts, but callers in other units reason from the contract. In Varc, pub declarations form the interface. In Vibe, module-level names not starting with _ form it.
A package's private part contains declarations visible to its implementation but hidden from ordinary clients. Private types expose permitted operations without exposing fields. Package bodies can have initialization statements; those statements execute during elaboration, before the application's main operation.
Scope and name resolution
Declarations belong to scopes. Nested scopes can hide outer declarations; same-scope duplicates that are not valid overloads are errors. A declaration is ordinarily available after its declaration point, with deferred resolution for contracts and type protocols where the implementation explicitly provides it. Declaring a function does not import all the names from its implementation's dependencies into callers.
Vada folds identifier case. Varc preserves case-sensitive source identities through its frontend mapping. Vibe also has case-sensitive source spellings, but the extracted Ada-like unit model folds case: two declarations of a module that differ only in case are rejected. See the syntax references for escaped identifiers.
Use a selected name, such as Counters.Advance, to identify a member explicitly. Vada's use Package and Varc's corresponding use make visible declarations candidates for direct lookup. use type T exposes operators of a type; use all type T also exposes the relevant primitive operations. Making two same-named declarations visible can create ambiguity rather than selecting the most recently imported one.
private with P; (Varc private import P;) makes P available to the package's private part and body only. A private child unit is visible only within its parent's subtree. limited with P; (Varc limited import P;) lets two package specifications name each other. Where P has not been analysed yet, because it names this unit itself, the unit sees the limited view of P: each type P's visible part declares, as an incomplete type (tagged where the type is tagged), usable where an incomplete type is, such as the designated type of an access type. Units that name P with an ordinary with see all of it, and the incomplete types are the same types once P is analysed. Where P needs nothing from this unit, limited with P; means with P;: P's types are then complete types and its other declarations can be named, uses that Ada refuses through a limited view. A cycle of ordinary with clauses is still B1006: put the shared declarations in a third package that both name, or move a dependency that only the implementation needs into the body.
Vibe's import m, import m as n, from m import f and from m import f as g bind names as Python does; the Vibe module reference gives the details.
Overloading and visibility
Subprograms and enumeration literals can share names when the language can resolve their profiles. The expected argument and result types help choose a candidate. If more than one candidate remains, explicitly convert or qualify a value or qualify the member name. Return-type context can distinguish functions, but a variable's spelling alone cannot resolve an ambiguous call.
Operators are operations with visibility rules. Importing a package containing a type does not necessarily make every operator of that type directly visible. For Vada, add use type or call an explicitly qualified operation when B1012 identifies an invisible operator. Vibe source uses supported inferred operators; it is not a general implementation of Python special-method dispatch.
Child units and subunits
Vada supports child packages and private children, and separate subunits completing body stubs. A child has a relationship with its parent package and must obey the corresponding visibility and dependency rules; a dot in a selected object name does not declare a child. A subunit is an implementation completion associated with a parent body, not a second independent package interface. The driver splices subunits into their parents before analysis, in a project and in a build of files alike: it finds a subunit in the file named after its parent and itself (main-report.vadb for Main.Report), and loads the units the subunit's own context clause names. A subunit's parent is named by its full expanded name: separate (Main.Inner) for a stub in the package body Inner nested in Main, and separate (Pkg.Sub) for a stub in the subunit Pkg.Sub, in main-inner-hello.vadb and pkg-sub-sub2.vadb. The body of a task or a protected object may be a subunit too: task body Worker is separate; and protected body Counter is separate; in the package body (Varc task body Worker separate;), completed by separate (Workers) task body Worker is ... end Worker; in workers-worker.vadb, which is checked, run and proved as if written in its place.
A package nested in another unit may have a body whether its specification needs one or not; a library package has one only when its specification needs one (including a nested package whose specification needs one) or says Elaborate_Body (B1016). A body never stands in a specification.
Varc writes child units and subunits with the forms in its units chapter. Vibe has no private children or subunits; a Vibe module can still depend on such units written in Vada or Varc.
Renaming
A renaming introduces another view of an existing object, package, exception, or subprogram; it does not inherently create a copy. An object renaming of a component designates that component, with indices resolved when the renaming is elaborated. Subsequent operations still obey mutability, ownership, and aliasing restrictions. A package renaming changes how the package is named, not the identity of its types or generic instances. A package renaming can be a library unit of its own (package Short renames Long_Package_Name; in short.vads); units that with Short then name the renamed package through it.
Vada's X : T renames Y; is different from X : T := Y;, which initializes another object and may copy or move a value. Python-looking assignment and import ... as ... are not general replacements for renaming in Vibe. Consult ownership and Vibe's sharing rules before choosing a spelling to express an alias.
Elaboration and initialization
Elaboration creates declarations and performs their initializations in dependency order. Specifications precede uses; a package body follows the needed specification and dependency ordering. Cyclic or unsafe elaboration dependencies are diagnosed. The order in which a directory happens to list files is not the program's initialization contract.
Flow analysis checks that a global is initialized before it is read, including reads through called operations during elaboration. Initializes describes the package state initialized by its elaboration. Elaborate_Body requests the relevant body relationship. Pure and Preelaborate are accepted without effect (see aspects and pragmas), since Verada computes the elaboration order itself.
Task threads are activated after library elaboration. Package initialization must therefore establish the shared state they need before activation. Native execution and the supported REPL library session have different loading lifecycles; the Toolchain Manual describes elaboration once per REPL session and the effect of reset.
Main programs
Use one unambiguous parameterless library procedure as main. Vada commonly uses procedure Main; Varc uses an equivalent top-level function without a result; Vibe uses a module-level def main() -> None (or the function its if __name__ == "__main__": calls). A program has one main procedure; keep independent programs in separate projects. After native main returns, the program waits for tasks; returning from main is not necessarily process termination when tasking is present.
Project discovery, explicit input precedence, nonrecursive source enumeration, C sources, and output paths are operational rules documented in the Toolchain Manual. They do not alter language visibility or make an illegal unit arrangement legal.