Draft specification, RFCs, reference registries and examples, plus the reference-implementation skeleton: build.zig, diagnostic envelope with error-code registry synced to docs, aji CLI, conformance runner with seed tests, CI and contributor docs.
1.1 KiB
06. Resources and Errors
1. Linear resources
External resources are linear unless explicitly documented otherwise.
Examples:
File
Socket
Thread<T>
Task<T>
Mapping
Timer
Device
A linear resource must be consumed by exactly one valid terminal action such as close, join, release or ownership transfer.
The verifier rejects double consumption and use after consumption.
2. Typestate
Resources MAY encode state transitions in types.
Example socket states:
Socket<Created>
Socket<Bound>
Socket<Listening>
Socket<Connected>
Socket<Closed>
A transition consumes one state and returns another.
3. Cleanup
Aji may provide defer as syntax sugar:
let file = fs.open(...)?;
defer fs.close(move file);
AIR must contain explicit cleanup control-flow edges. Aji has no hidden destructors.
4. Result
Expected failure uses Result<T, E>.
Propagation syntax may exist only if its lowering is explicit and does not introduce exceptions or unwinding.
5. Trap versus Result
Use Result for failures callers may reasonably handle.
Use trap for invariant violations, failed assertions and explicitly trapping primitives.