cli: add whole-value linear aggregates
Implement STD-5 through source, AIR, verifier and deterministic interpreter. Constructors consume nested owners; exhaustive unpack/take, explicit swap and own.pack preserve ownership on success and failure. Support owning Option and Result while keeping classification helpers Copy-only. Preserve borrow identity across whole replacement and collection; distinguish individual owned arrays from repeated heap arrays. Specify feature contracts, invariants, diagnostics, compatibility and measured source/AIR budgets in RFC 0023 and normative docs. Add canonical round trips, AIR/source acceptance and rejection fixtures, CLI integration and CI checks. Validate build, unit/extended tests, full conformance, forced-collection schedule stress (32 seeds per quantum), hosted smoke, CLI suites, source coverage (88/88), formatting and reference bundle generation. Source bundle grows 3.2%; Quick Reference grows 4.0%. No MCC improvement is claimed. Dynamic initialized linear buffers and explicit drain remain Q-036/STD-6; frame/region/repeated heap storage is Copy-only. RFC remains Proposed.
This commit is contained in:
109 files changed
+1814
-142
No files matched your search
@@ -104,3 +104,6 @@ RFC 0020 supplied-buffer decimal formatting (cl100k, relative to text): Quick Re
|
||||
RFC 0021 package modules (cl100k, relative to formatting): Quick Reference 6,220 → 6,501 (+4.5%); other source docs 37,128 → 38,822 (+4.6%); full source docs excluding AIR 43,348 → 45,323 (+4.6%). New on-demand `language/modules.md` is 1,566 tokens, library/std.md and AIR remain unchanged. The front door has one checked module example; package input/name/loader contracts stay on demand. Cumulative source growth is +33.4%, documented for owner review; no compression benefit is claimed. Pure modules need no new AIR feature or verifier state.
|
||||
|
||||
RFC 0022 explicit generics (cl100k, relative to modules): Quick Reference 6,501 → 6,948 (+6.9%); other source docs 38,822 → 41,086 (+5.8%); full source docs excluding AIR 45,323 → 48,034 (+6.0%). New on-demand `language/generics.md` is 1,324 tokens; `library/std.md` is 8,380 tokens. AIR remains 160,797 bytes. Cumulative source growth is +41.3%, and Quick Reference exceeds its 4–6k target; the RFC explains the cost for owner review and calls for separate front-door consolidation/selective API reading. Explicit specialization adds no AIR instruction or verifier transfer state; documentation growth alone does not establish a compression benefit.
|
||||
|
||||
|
||||
RFC 0023 whole-value linear aggregates (cl100k, relative to generics): Quick Reference 6,948 → 7,225 (+4.0%); other source docs 41,086 → 42,364 (+3.1%); full source docs excluding AIR 48,034 → 49,589 (+3.2%). New on-demand `language/linear-aggregates.md` is 1,133 tokens; `library/std.md` is 8,398. AIR grows to 168,336 bytes (+4.7%). Whole unpack/exhaustive match/explicit swap/allocation failure expose ownership without per-field holes, cleanup or new transfer state. Cumulative source growth is approximately +45.9%; Quick Reference remains beyond its 4–6k target. RFC 0023 justifies the added contracts; consolidation remains separate work and no MCC improvement is claimed.
|
||||
@@ -86,3 +86,6 @@ docs/reference/air-features.md
|
||||
docs/reference/effects.md
|
||||
docs/reference/capabilities.md
|
||||
docs/reference/intrinsics.md
|
||||
|
||||
# Whole-value linear aggregates (STD-5)
|
||||
docs/spec/03-memory-model.md :: ## 25. Linear aggregates in AIR
|
||||
@@ -407,6 +407,22 @@ fn main() -> u64 effects [] {
|
||||
}
|
||||
```
|
||||
|
||||
`std.option.Option<T: Copy>` has `some(T)`/`none`; `std.result.Result<T: Copy, E: Copy>` has `ok(T)`/`err(E)`. `is_some::<T>` and `is_ok::<T, E>` classify them; match to extract payloads. Owning/borrowed payloads still reject. Unknown names: `E7002`; missing/extra arguments, duplicate/unknown constraints or expansion limits: `E7006`; unsatisfied constraints: `E7005` with `parameter`, `constraint`, `found`. Borrow conflicts, moves, effects and cleanup keep their existing rules.
|
||||
`std.option.Option<T>` has `some(T)`/`none`; `std.result.Result<T, E>` has `ok(T)`/`err(E)`. `is_some::<T>` and `is_ok::<T, E>` classify Copy specializations; match to extract payloads. Owning payloads follow §13; borrowed payloads reject. Unknown names: `E7002`; missing/extra arguments, duplicate/unknown constraints or expansion limits: `E7006`; unsatisfied constraints: `E7005` with `parameter`, `constraint`, `found`. Borrow conflicts, moves, effects and cleanup keep their existing rules.
|
||||
|
||||
Each required specialization is checked as concrete code; an unused template body is not a proof for future types. `Copy` gives no arithmetic or ordering operation. Read `/docs/language/generics.md` for exact Copy/Send/Share/Freeze/Local rules, deterministic keys and fixed limits; `/docs/library/std.md` for option/result contracts.
|
||||
|
||||
## 13. Linear aggregates
|
||||
|
||||
A struct/enum/fixed array containing owners or resources is linear. Construct with `move`; consume it completely. Read Copy fields normally. A linear enum needs exhaustive `match move`; even none must be consumed. No partial moves or automatic cleanup.
|
||||
|
||||
```aji
|
||||
struct Item { owner: own<u64> }
|
||||
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
|
||||
let owner = own.new(42u64, heap) or trap;
|
||||
let value = Item { owner: move owner };
|
||||
let (part) = struct.unpack(move value);
|
||||
return own.take(move part);
|
||||
}
|
||||
```
|
||||
|
||||
`[move a, move b]` constructs ordered array elements; `let (a,b) = array.unpack(move data);` extracts every element. `value.swap(mut place, move replacement)` returns the old complete value. `own.pack(move value, heap)` has ok(owner) and err(error, original_value); own.take extracts linear content, while own.free cannot destroy it. Dynamic heap arrays/regions/frame storage remain Copy-only. Owning std.option/std.result use ordinary linear enums; is_some/is_ok retain Copy constraints. Full contracts: language/linear-aggregates.md.
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
> QUICK.md
|
||||
docs/agent/quick-reference.md
|
||||
docs/agent/source-notes.md :: ## 13. Where to read more
|
||||
docs/agent/source-notes.md :: ## 14. Where to read more
|
||||
|
||||
> language/syntax.md
|
||||
docs/reference/grammar.ebnf
|
||||
@@ -21,6 +21,10 @@ docs/spec/15-source-language.md :: ## 6. Fallible operations and `match`
|
||||
|
||||
docs/spec/15-source-language.md :: ## 13. Built-in standard modules
|
||||
|
||||
> language/linear-aggregates.md
|
||||
docs/spec/15-source-language.md :: ## 16. Source linear aggregates
|
||||
docs/spec/03-memory-model.md :: ## 25. Linear aggregates in AIR
|
||||
|
||||
> language/generics.md
|
||||
docs/spec/15-source-language.md :: ## 15. Explicit source generics
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
Text that exists only for the Source Reference Bundle (`source-bundle.txt`). Non-normative: it points at the normative files and states which source layers are implemented.
|
||||
|
||||
## 13. Where to read more
|
||||
## 14. Where to read more
|
||||
|
||||
The other files in `/docs` hold the full rules. Open one only when this page is not enough.
|
||||
|
||||
| Need | Read |
|
||||
|---|---|
|
||||
| built-in bytes/math/UTF-8/hex/Base64/decimal integers, signatures and failure contracts | `/docs/library/std.md` |
|
||||
| whole-value linear aggregates, unpack, exchange and allocation failure | `/docs/language/linear-aggregates.md` |
|
||||
| generic declarations/applications, property constraints and specialization limits | `/docs/language/generics.md` |
|
||||
| explicit package imports, qualified types, manifest file inputs | `/docs/language/modules.md` |
|
||||
| exact syntax, every construct, `match` and outcomes | `/docs/language/syntax.md` |
|
||||
|
||||
Reference in new issue
Block a user