On this page
Values, resource ownership and expected errors
Verada combines value semantics with checked ownership. Knowing whether a value is copied, moved to a new owner or lent out for a while prevents both program bugs and confusing proof failures.
Begin with values
The stockroom shelf is a fixed array of bounded integers. Assigning it copies it, and referring to its entry value in a postcondition takes a snapshot; nothing is shared and nothing needs cleaning up. That is why it makes a good first abstraction.
A record can hold plain values or parts that own allocated storage. Copying a record of scalars is cheap and harmless; copying a pointer to allocated storage would create two owners, so Verada does not allow it. A limited type cannot be copied at all.
Ownership
An owning access value (a pointer) is responsible for one allocated object. Assigning it to another variable moves that responsibility: the source can no longer be read as if it still owned the object, until you give it a new value. There is never a second independent owner of the same object.
A record or container can own several parts. Moving one part out makes the whole value unreadable until that part is restored. When branches of an if or iterations of a loop leave ownership in different states, Verada requires them to agree where the paths join.
Freeing a node does not free what its fields point to. Use the cleanup operation the type or library provides, and make sure every owner is either moved on or freed. The ownership chapter has complete examples.
Borrow or observe for a while
A borrow gives temporary exclusive access to part of an owned structure; while it lasts, the owner cannot be used in a way that conflicts with it. An observer gives read-only access and stops the structure from changing underneath it.
Use a borrow or observer to visit or update storage without taking ownership, and let it end before using the owner again. It cannot be stored somewhere that outlives it, and you cannot resize a container while you hold a view of one of its elements.
Vada and Varc express these with anonymous access types and renamings. Vibe has local views and element views; an element view writes its value back when its statements end. The Vibe sharing chapter gives the accepted and rejected patterns.
Say what you mean about copies in Vibe
Python stores references; Verada stores values or moves owners. Where that difference would change what a program prints, Vibe rejects the program instead of silently behaving differently. The common case is "store an object, then change the original": in Python the stored object changes too. Either make the change before storing, or state that you want an independent copy, whichever matches what the program should do.
Neither "every assignment copies" nor "every assignment shares" is the rule; the sharing chapter says exactly which forms do what.
Reclaim resources through an abstraction
A type with finalization runs its cleanup when an object of the type goes out of scope, including when an exception leaves the scope. A limited resource cannot be copied; a copyable one supplies an adjust operation so each copy owns its own resource. The library's Text works this way and behaves as a plain value.
Finalization in Verada is relaxed: cleanup happens when objects go out of scope, not when the program ends, so an action that must happen at exit belongs in the main program, not in a library-level object's finalizer. Finalize and adjust operations must terminate and cannot have preconditions, because they are called implicitly.
Prefer a library type to writing your own finalization. When you need one, ownership gives the syntax and rules.
Decide how expected failure is represented
The stockroom reservation can legitimately fail when a bin has too little stock; that is part of the business. The operation returns a Boolean outcome and promises that a declined request changes nothing.
The restock operation instead requires its caller to ensure the delivery fits. That suits an internal operation whose caller has already validated the delivery. A service that accepts deliveries from outside would have to check them first, or report a handled outcome.
The choices for an expected failure are a status result, an optional value, or a declared exception with an exceptional contract. Choose what callers can handle. A failed proof is never the way to report an expected rejection.
Exceptions describe abnormal outcomes
A subprogram may propagate only the exceptions it declares, and each declaration says what holds when that exception is raised. A normal return still has its postcondition. Handling an exception does not undo the changes the operation already made.
Exceptions in Verada are for application outcomes. A run-time check that fails, such as an overflow, is a bug that proof rules out; it is not something to catch and carry on from. See user exceptions.
Diagnose a resource error
Start from the operation that changed ownership, not the later use that was rejected. For a use after a move, find the move and decide whether it should have been a move, a copy or a borrow. For a borrow conflict, end the borrow sooner or move the conflicting operation. For a leak, find the owner that would be lost or overwritten and give it its cleanup.
If two parts of the program really need to share mutable structure, as in a graph, use an arena with handles, or a proof enclave that hides a shared representation behind a value-like API.
A good exercise: follow one owner through every branch and mark who must clean it up on a normal return and on an exception. Each ownership diagnostic then points at a missing move, restoration or cleanup.