Owner decisions D1-D7 and the boundary rule (source may hide representation mechanics, never authority, allocation, ownership transfer, synchronization, external effects or recoverable failure). spec 15 normative: items, types, statements, expressions, places and borrows, explicit move (named values), outcome matches and 'or trap', scope/shield/lock blocks (lock lowering defined exactly), select, channels, allocation, frame storage, lexical borrow scopes, inferred features, one canonical spelling per construct. grammar.ebnf replaced; E7001-E7007; E3101 gains suggested_effects; spec 01 examples updated.
2.8 KiB
01. Language Overview
1. Purpose
Aji is a low-level systems language optimized for generation, verification and repair by AI agents.
The language intentionally has a smaller semantic surface than conventional general-purpose systems languages.
2. Explicit by default
Aji has no implicit:
- heap allocation;
- reference counting;
- exception propagation;
- destructor execution;
- network/filesystem authority;
- dynamic dispatch;
- integer conversion;
- thread detachment.
The compiler MAY provide source syntax that lowers to explicit AIR, but the semantic operation MUST remain visible in AIR.
3. Program structure
Illustrative source:
module example
fn add(a: u64, b: u64) -> u64
effects []
{
return a + b;
}
The normative source language is specified in spec 15.
A program is composed of:
- modules;
- type declarations;
- constants;
- function declarations;
- explicit imports;
- optional contracts;
- explicit effect declarations.
4. Control flow
Core structured source constructs are:
if/else;while;forover verifier-recognized ranges/iterators;match;break;continue;return.
AIR lowers these constructs to basic blocks, branches, block parameters and terminators.
5. Error handling
Aji has no exceptions.
Fallible operations have explicit outcomes. In .aji 0.1 every outcome is an arm of a match (spec 15 §6):
match fs.read(file, mut buffer) {
ok(n) => { consume(n); }
err(e) => { return Status.ReadFailed; }
}
Stack unwinding is not part of the language.
6. Trap
A trap is a defined abnormal termination of the current execution context according to runtime policy.
Common trap sources:
- checked arithmetic overflow;
- failed assertion;
- impossible match state in unsafe code;
- bounds failure in trapping indexing;
- explicit
trap.
Safe programs SHOULD prefer Result for expected failures.
Every trap has a stable code in the T0xxx range of ../reference/error-codes.md. A trap terminates the program; in format version 0 there is no way to observe a trap from inside the program. The implementation reports a trap record containing the code, kind, function, block and the zero-based index of the trapping instruction within its block. Trap records are deterministic: the same module and inputs produce the same record.
7. Generics
Aji supports monomorphized generics.
fn swap<T>(a: mut<T>, b: mut<T>) { ... }
Version 0.1 does not require user-defined traits/typeclasses. Generic constraints use compiler-known structural properties such as Copy, Send, Share, Freeze and Local.
8. Compilation principle
Aji source is not the normative execution format. AIR is.
A source feature is acceptable only if its lowering to AIR is deterministic, explicit and mechanically verifiable.