DEVELOPMENT EDITION · 769442725406
Vibe syntax
On this page

Names, modules, and local scope

A Vibe file defines a module. Its filename without .vb is the module/package name, so accounts.vb supplies accounts. Verada finds modules in the project's source directories when it compiles; there is no run-time sys.path search or package installation.

Module structure and the executable entry

A normal module contains imports, module objects, type declarations, classes, functions, and supported initialization statements. Its public interface is extracted automatically; you do not write a second specification file. Declarations needed by callers go into that interface, while implementation bodies and initialization remain implementation details. The shared program structure explains loading and elaboration.

The program's entry is the module's main function: a parameterless function returning None. When the main guard calls another function of the module, if __name__ == "__main__": run(), that function is the entry instead. The main module can declare its own functions and classes beside it; reusable declarations belong in imported modules:

from accounts import report


def main() -> None:
    report()


if __name__ == "__main__":
    main()

This is a layout fragment; accounts.report must exist. The guard if __name__ == "__main__": ... (with no else) names the entry; Verada calls the entry directly, so the guard's body is not a separate startup step. The guard lets the same file run under Python (Python execution).

A Vibe module is a library package. Child units, separate subunits and renamings of packages are written in Vada or Varc; a Vibe module imports them by their dotted names.

Module-level executable statements become package initialization and run in dependency order before the main program. Verada checks for cyclic or unsafe initialization dependencies.

Import forms

Source Meaning
import accounts Make the accounts unit available; write accounts.deposit(...)
import company.accounts Import a dotted unit; write company.accounts.deposit(...)
import accounts as acc The same, with acc as the unit's name in this module: acc.deposit(...)
from accounts import deposit Bind deposit alone; the unit's other names are not visible unqualified
from accounts import deposit as put Bind deposit under the name put
from accounts import deposit, withdraw Bind several names; parentheses may wrap the list
from accounts import * Bind every public name of the unit

Imports are absolute, and each import statement names one unit. A name a module uses must be its own, a builtin, or imported: using another of a unit's names after from accounts import deposit is B1001, whose message gives the from ... import line that would bind it.

Imports from verada, typing, dataclasses, enum, abc and itertools, and from __future__ ..., bring in Vibe's recognized helpers and load no unit. Only those helpers have Vibe meaning: import itertools does not make every itertools function available.

Case and visibility

Local names are case-sensitive. A module-level name starting with _ is hidden from the extracted public interface; other declarations are public. Importing a hidden name, from helper import _hidden, is B1001 at the import. Class fields are subject to Verada's visibility model, not Python name mangling: use consistently public fields or the supported private-field form rather than mixing conventions casually.

Module declarations that differ only by case are rejected with B0401. For example, class Buffer ... and buffer = Buffer() in the same module collide; choose a distinct object name such as shared_buffer. A field whose name differs only by case from its type name is also rejected, such as items: Items. Rename the field or type. These restrictions are checked before the shared case-sensitive-name translation, and changing imports does not repair them.

Names from Vada and Varc libraries are resolved without regard to case, as Ada resolves them, so they can be written in PEP 8 spelling: import ada.exceptions and ada.exceptions.exception_message(occurrence). Spell a qualified name's prefix as the import statement spells the unit.

Objects, initialization, and constants

At module level, count = 0 declares an inferred variable. count: int = 0 declares a typed variable. LIMIT: Final[int] = 100 declares a constant; LIMIT: Final = 100 can be a static named number. A typed module container such as seen: list[int] = [1, 2] is filled in order when the module is initialized. started: Suspension_Object, an annotation with no value, declares a variable of a type that gives its objects their value (initialised by default, as a local so annotated is); one of another type must be given a value before it is read, which the prover checks.

Within a function, the first assignment to a new name introduces a local object. Its type is inferred from the initializer when possible. It is treated as constant when later code does not reassign or potentially mutate it; otherwise it is a variable. Calls and views participate conservatively in that decision. Inference never grants unbounded values or arbitrary dynamic type changes.

A local first introduced inside an if or loop has that statement-list scope. If it is needed afterward, declare it before the branch/loop, with a type and suitable initialization:

answer: int = 0
if use_first:
    answer = first
else:
    answer = second
print(answer)

This function-body fragment assumes typed use_first, first, and second. A declaration with no initializer is allowed locally where the type and flow rules can establish that it is assigned before reading. Definite initialization is still required on every path.

Component mutation such as point.x = ... changes the caller's object and makes the parameter writable; see subprograms. A function changes a variable of its own module as Python's does, after global count: then count = count + 1 assigns the module's count rather than declaring a local one (count += 1 changes it too). global of a name that is not a variable of the module is B0401: another module's variables are changed through that module's functions. Forward references and overload resolution follow the compiler units and the shared rules, not Python's late-bound name lookup.

Identity across modules

Class, generic, and container types have nominal identity: matching field shapes or type spellings do not make independently generated instances interchangeable. A client uses the instances its defining module declares; the generic reference describes what the defining module must declare.

Source evidence: module extraction/imports, case-sensitive naming, and unit loading.