- text AIR format 0: grammar (reference/air-text.ebnf) and module, block, SSA, type and canonical-form rules (spec 07 §8) - instruction contracts for format 0 (new spec 07a) - traps: stable T0xxx codes and trap records (spec 01 §6) - integer edge cases and explicit casts (spec 02 §2.1) - fixed verifier resource limits (spec 08 §7) - target description with pointer_bits (spec 09 §9) - new codes E0001-E0006, E1003, T0001-T0007 - resolves Q-001, Q-003..Q-008, Q-018; Q-002 resolved for format 0
108 lines
2.7 KiB
Markdown
108 lines
2.7 KiB
Markdown
# 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:
|
|
|
|
```aji
|
|
module example;
|
|
|
|
fn add(a: u64, b: u64) -> u64
|
|
effects []
|
|
{
|
|
return a + b;
|
|
}
|
|
```
|
|
|
|
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`;
|
|
- `for` over 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 return `Result<T, E>`.
|
|
|
|
```aji
|
|
match fs.read(file, buffer) {
|
|
Ok(n) => consume(n),
|
|
Err(e) => return Err(e),
|
|
}
|
|
```
|
|
|
|
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`](../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.
|
|
|
|
```aji
|
|
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.
|