Specialize explicit function, struct and enum templates into deterministic ordinary AIR, with structural constraints and bounded expansion. Preserve source provenance and readable names in specialization diagnostics. Add Copy-only std.option/std.result and vertical specification, grammar, Quick Reference, RFC and source coverage updates. Keep linear aggregates and existing unsupported source from-returns explicit follow-up work. Repair the finite-layout check through arrays under the existing E1003 contract, with positive and rejected source/AIR fixtures. Validation: build, unit tests, 640 conformance cases, 82/82 source constructs, 32-seed generic task stress, agent-reference, formatting, hosted smoke, 20 generic and 36 package CLI checks. Record three-encoding documentation budgets; AIR reference is unchanged.
110 lines
3.0 KiB
Markdown
110 lines
3.0 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;
|
|
}
|
|
```
|
|
|
|
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`;
|
|
- `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 have explicit outcomes. In `.aji` 0.1 every outcome is an arm of a `match` (spec 15 §6):
|
|
|
|
```aji
|
|
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`](../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 explicit monomorphized generics (source contract: spec 15 §15). Calls use `swap::<u64>(mut a, mut b)`; type annotations use `Pair<u64>`.
|
|
|
|
```aji
|
|
fn swap<T: Copy>(a: mut<T>, b: mut<T>) -> void effects [] { ... }
|
|
```
|
|
|
|
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.
|