docs: align source overview with specified extensions
This commit is contained in:
1 parent
edfef82cc6
commit
94414dac3c
6 files changed
+23
-17
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# 15. Source Language `.aji` 0.1 (Phase 6A)
|
||||
# 15. Source Language `.aji` 0.1
|
||||
|
||||
This file is normative for `.aji` source 0.1. Decision record: RFC 0013. Grammar: [`../reference/grammar.ebnf`](../reference/grammar.ebnf).
|
||||
This file is normative for `.aji` source 0.1. Initial decision record: RFC 0013; subsequent extensions are specified below. Grammar: [`../reference/grammar.ebnf`](../reference/grammar.ebnf).
|
||||
|
||||
## 1. Principle
|
||||
|
||||
@@ -30,8 +30,8 @@ It MUST NOT hide:
|
||||
Rules:
|
||||
|
||||
1. Lowering is a pure function of its explicit source inputs: the same module graph gives byte-identical canonical AIR (spec 07 §8.5).
|
||||
2. No source construct admits a program whose AIR the verifier rejects. Errors the verifier would find are reported with the verifier's code (§9).
|
||||
3. `.aji` 0.1 covers the published features of Phases 0–3 and nothing else.
|
||||
2. No source construct admits a program whose AIR the verifier rejects. Diagnostics follow §10 and the construct-specific rules below.
|
||||
3. `.aji` 0.1 covers the constructs specified here and nothing else, including the extensions to the initial Phases 0–3 baseline.
|
||||
4. Every construct has **one canonical spelling**. There are no alternative forms of the same operation. Parentheses for expression grouping and the optional list delimiters of §2 do not introduce operations.
|
||||
|
||||
## 2. Modules and declarations
|
||||
@@ -146,7 +146,7 @@ Lowering: structured control flow becomes blocks and terminators. A variable ass
|
||||
|
||||
| Source | AIR |
|
||||
|---|---|
|
||||
| `x as T` | `cast.widen`; only where every value is representable, otherwise `E1002` |
|
||||
| `x as T` | `cast.widen`; only where every value is representable, otherwise source `E7005` (§10; AIR `E1002`) |
|
||||
| `x as! T` | `cast.checked` (`T0006`) |
|
||||
| `x as% T` | `cast.wrap` |
|
||||
|
||||
@@ -154,7 +154,7 @@ Lowering: structured control flow becomes blocks and terminators. A variable ass
|
||||
|
||||
- integers (`42`, `0xff`, `0b101`, `1_000`) take their type from context, or a suffix (`42u8`);
|
||||
- `true`, `false`;
|
||||
- `b"…"`: a byte string, of type `[u8; N]`, with escapes `\n`, `\t`, `\\`, `\"`, `\xHH`.
|
||||
- `b"…"`: a byte string, of type `[u8; N]`, with escapes `\n`, `\r`, `\t`, `\\`, `\"`, `\0`, `\xHH`.
|
||||
|
||||
**Aggregates.**
|
||||
|
||||
@@ -163,7 +163,7 @@ Lowering: structured control flow becomes blocks and terminators. A variable ass
|
||||
- **Arrays.** `[e; N]` is `array.splat`.
|
||||
- **Field access.** `v.f` on a struct value is `struct.get`.
|
||||
|
||||
6A has no destructuring: no `let Point { x, y } = p`, no nested patterns, guards or or-patterns.
|
||||
There is no pattern destructuring: no `let Point { x, y } = p`, no nested patterns, guards or or-patterns. Complete aggregate unpacking is specified in §16.
|
||||
|
||||
**Calls.** `f(args)` calls a local function; a directly imported function uses its full path (§13–§14). Built-in operations are called by their AIR names (§7, §8). Arguments are evaluated left to right.
|
||||
|
||||
@@ -185,7 +185,7 @@ Lowering: structured control flow becomes blocks and terminators. A variable ass
|
||||
| `s[i]` | element value (borrow, load, end) |
|
||||
| `s.len` | `slice.len`, or the static length of an array |
|
||||
| `s[a..b]` | a sub-slice (`slice.sub` with start `a`, length `b - a`); a borrow, so it is bound or passed, never a value |
|
||||
| `let (left, right) = s.split_at(k);` | `slice.split`: two disjoint borrows of `s`. Besides `atomic.compare_exchange` (§12), the only multi-result binding. There is no general tuple destructuring. |
|
||||
| `let (left, right) = s.split_at(k);` | `slice.split`: two disjoint borrows of `s`. Multi-result bindings also cover `atomic.compare_exchange` (§12) and complete aggregate unpacking (§16). There is no general tuple destructuring. |
|
||||
| `slice.copy(mut dst, ref src)` | primitive `slice.copy`; insufficient capacity traps. Recoverable byte copy is `std.bytes.copy` (spec 16 §2.4). |
|
||||
|
||||
**Whole-array arguments.** In an ordinary function call, `ref place` / `mut place` MUST preserve a whole-array referent when the known parameter is `ref<[T; N]>` / `mut<[T; N]>`; otherwise the existing whole-array-to-slice rule applies. Element type, length and explicit borrow mode MUST match (`E7005`); a slice MUST NOT be converted back to an array borrow. This also applies after explicit generic/static-function specialization and to array fields, elements and dereferenced array borrows (`ref (*a)`). Shared reborrowing of an exclusive parent follows the existing AIR rule. All temporary ancestors end after the call, child first. Borrow bindings still produce slices; bare byte-string arguments still produce `slice<u8>`. The named-origin requirement of §19 and the named-loan requirement of `task.spawn` (§7) remain mandatory.
|
||||
@@ -485,7 +485,7 @@ Spec 04 §20–§30, §42; layer 10, RFC 0015. Implemented with the publication
|
||||
| `atomic.swap(c, v, o)` | `atomic.xchg.<o>` |
|
||||
| `atomic.add.wrap(c, v, o)`, `atomic.sub.wrap(c, v, o)` | `atomic.add.wrap.<o>`, `atomic.sub.wrap.<o>` |
|
||||
| `atomic.and(c, v, o)`, `atomic.or(c, v, o)`, `atomic.xor(c, v, o)` | `atomic.and.<o>`, `atomic.or.<o>`, `atomic.xor.<o>` |
|
||||
| `let (old, exchanged) = atomic.compare_exchange(c, expected, desired, s, f);` | `atomic.cmpxchg.<s>.<f>`, the second multi-result binding |
|
||||
| `let (old, exchanged) = atomic.compare_exchange(c, expected, desired, s, f);` | `atomic.cmpxchg.<s>.<f>`, a multi-result binding |
|
||||
| `atomic.fence(o);` | `atomic.fence.<o>` |
|
||||
|
||||
The cell operand `c`:
|
||||
@@ -581,7 +581,7 @@ Structs, enums and fixed arrays with linear members MUST obey spec 03 §25. Cons
|
||||
|
||||
`value.swap(mut place, move replacement)` returns the previous complete value and stores the replacement; it lowers to value.swap with the existing borrow scope. The same spelling accepts Copy replacements without move. The caller MUST explicitly consume a returned linear value. `match own.pack(move value, heap) { ok(owner) => …, err(error, value) => … }` makes allocation authority/failure explicit and preserves ownership on both outcomes; `or trap` retains ordinary abnormal-path semantics. own.new/own.array/region storage and local storage remain Copy-only; own.take extracts whole linear content and own.free cannot destroy it.
|
||||
|
||||
The frontend MUST declare linear_aggregates plus its dependencies whenever any emitted aggregate has linear members or any of the new operations is emitted. Existing Source/AIR diagnostics and deterministic behavior apply. This phase does not implement partial moves, borrowed aggregates, dynamic linear buffers or source from-returns.
|
||||
The frontend MUST declare linear_aggregates plus its dependencies whenever any emitted aggregate has linear members or any of the new operations is emitted. Existing Source/AIR diagnostics and deterministic behavior apply. Partial moves and borrowed aggregates remain outside this surface; dynamic buffers and borrow returns are specified in §17 and §19.
|
||||
|
||||
|
||||
## 17. Source dynamic buffers
|
||||
@@ -592,7 +592,7 @@ Outcomes: new has ok(buffer)/err(alloc_error); reserve has ok()/err(alloc_error)
|
||||
|
||||
A specialized generic body MAY use `move name` to express complete value transfer for a type parameter. If its concrete binding is Copy, lowering passes the existing Copy value and it remains available; if linear, ordinary transfer/availability applies. This rule applies to complete Copy bindings inside a specialized generic body, not borrows or internal storage/scope/guard/shield handles. A Copy value bound in frame storage remains a Copy value and is loaded normally when transferred. Outside a specialized generic body, move of a Copy value remains E7006. No AIR ownership rule changes and no implicit destructor/allocation is added. This makes one generic container body correct for both Copy and linear contents; ordinary borrow/effect/type constraints still apply to every specialization.
|
||||
|
||||
The frontend MUST emit linear_buffers and its full dependencies for buffer types/operations. Existing syntax suffices apart from admitting the buffer wrapper and the typed built-in allocator with the existing channel.make<T> type-argument form. General methods, borrowed aggregate storage, recursive ownership and from-return calls are not added.
|
||||
The frontend MUST emit linear_buffers and its full dependencies for buffer types/operations. Existing syntax suffices apart from admitting the buffer wrapper and the typed built-in allocator with the existing channel.make<T> type-argument form. General methods, borrowed aggregate storage and recursive ownership remain outside this surface; borrow-returning calls are specified in §19.
|
||||
|
||||
## 18. Static function parameters
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ The specification is split by semantic domain. Rationale for major decisions liv
|
||||
| [12-packages-and-build.md](12-packages-and-build.md) | Normative draft | Manifest/build model |
|
||||
| [13-contracts-and-unsafe.md](13-contracts-and-unsafe.md) | Normative draft | Contracts, proof status and unsafe boundaries |
|
||||
| [14-agent-efficiency.md](14-agent-efficiency.md) | Normative draft (design objectives) | Agent efficiency, Model Capability Compression, design review requirement |
|
||||
| [15-source-language.md](15-source-language.md) | Normative draft | The agent-facing source language `.aji` 0.1 (Phase 6A), lowering to AIR |
|
||||
| [15-source-language.md](15-source-language.md) | Normative draft | The agent-facing source language `.aji` 0.1, lowering to AIR |
|
||||
| [16-standard-library.md](16-standard-library.md) | Normative draft | Standard library contracts and built-in pure modules |
|
||||
|
||||
## Reading order
|
||||
|
||||
Reference in new issue
Block a user