cli: implement explicit source borrow returns
This commit is contained in:
1 parent
715a8be491
commit
a9a0d63f27
78 files changed
+970
-48
No files matched your search
@@ -131,3 +131,8 @@ RFC 0033 bounded I/O (cl100k, relative to BinaryHeap): Quick Reference 8,284 →
|
||||
RFC 0034 owning buffered files (cl100k, relative to bounded I/O): Quick Reference 8,350 → 8,445 (+1.1%), other source docs 58,473 → 61,223 (+4.7%), full source excluding AIR 66,823 → 69,668 (+4.3%). library/std.md is 24,364 tokens; AIR remains 179,282 bytes / 51 sections. Ten safe concrete operations keep fixed allocation, file transfer, prefetch and first-error/partial-write cleanup visible. No new syntax, diagnostic or verifier/runtime state; cumulative source growth is +105.0%, justified by these contracts without an empirical MCC claim. Full representation/API details stay on demand; front-door consolidation remains separate work.
|
||||
|
||||
RFC 0035 caller-buffer paths (cl100k, relative to buffered files): Quick Reference 8,445 → 8,518 (+0.9%), other source docs 61,223 → 63,296 (+3.4%), full source excluding AIR 69,668 → 71,814 (+3.1%). library/std.md is 26,437 tokens; AIR remains 179,282 bytes / 51 sections. Six pure operations return raw Copy ranges or write a measured canonical prefix, keeping lifetime, byte syntax, capacity failure and authority visible. No new syntax, diagnostic or verifier/runtime state; cumulative source growth is +111.3%, justified by these contracts without an empirical MCC claim. API details stay on demand; front-door consolidation remains separate work.
|
||||
|
||||
|
||||
RFC 0036 (Proposed), explicit source borrow returns (cl100k, relative to paths): Quick Reference 8,518 → 8,642 (+1.46%), other source docs 63,296 → 64,160 (+1.37%), full source excluding AIR 71,814 → 72,802 (+1.38%). language/ownership.md is 1,834 tokens; AIR remains 179,282 bytes / 51 sections. Existing `from`, ref/mut bindings and named returns reuse verifier/runtime primitives; frontend ancestry selects transferred lexical ends. No new keyword, AIR feature, verifier state or diagnostic. Cumulative full-source growth is +114.24%, justified in the proposed RFC without an empirical MCC claim. This measurement records the implementation for review, not owner adoption.
|
||||
|
||||
RFC 0036 review fixes clarify reserved task borrow returns and known array bounds in unused generic signatures. These rules add 54 cl100k tokens: other source docs 64,160 → 64,214, full source 72,848 → 72,902 (+0.07%); Quick Reference stays 8,688. o200k groups are 8,723 / 64,413 / 73,136; Qwen2.5 8,954 / 65,794 / 74,748. language/ownership.md is 1,873 cl100k tokens; AIR and library/std.md stay unchanged. The additions make source rejection predictable without adding a semantic feature.
|
||||
@@ -101,11 +101,18 @@ Rules (checked by the verifier):
|
||||
|
||||
- **A borrow lives until the end of the block where it was bound** (`ref r = …;` / `mut r = …;`). A borrow written as an argument (`f(mut buf)`) lives for that call. To end one early, put it in an inner `{ … }` block.
|
||||
- **Exclusive XOR shared.** While a `mut` borrow of a place is live, no other borrow of the same place, and no direct use of it, is allowed (`E2101`). Disjoint fields and `split_at` halves are independent.
|
||||
- A borrow cannot outlive what it borrows from (`E2102`). A function returns a borrow only with `-> ref<T> from param`.
|
||||
- A borrow cannot outlive what it borrows from (`E2102`). A function returns a borrow only with explicit `from param`. Bind returned views with `ref`/`mut`; the `from` argument must be a named borrow. Return the bound name without `move`; a local-frame view cannot escape (`E2108`).
|
||||
- **Moves are explicit:** a named linear value is consumed only as `move x` (otherwise `E7003`). A fresh temporary needs no `move`: `consume(make())`. Copyable values are passed plainly; `move` on them is `E7006`.
|
||||
- Use after move is `E2001`, use after close/free/take `E3001`, a second consumption `E2002`, and a linear value never consumed `E3002`. Every path must consume it, including early `return`s.
|
||||
- Index proofs: inside `if i < s.len { … }` the access `s[i]` needs no runtime check.
|
||||
|
||||
Returned views (details in `/docs/language/ownership.md`):
|
||||
|
||||
```aji
|
||||
fn first(s: slice<u64>) -> ref<u64> from s effects [] { ref item = s[0]; return item; }
|
||||
fn main() -> u64 effects [] { let data = [42u64, 7u64]; ref s = data; ref item = first(s); return *item; }
|
||||
```
|
||||
|
||||
## 5. Failure: every outcome is a `match` arm
|
||||
|
||||
```aji
|
||||
|
||||
@@ -48,6 +48,7 @@ docs/reference/type-properties.md
|
||||
docs/spec/01-language-overview.md :: ## 6. Trap
|
||||
|
||||
> language/ownership.md
|
||||
docs/spec/15-source-language.md :: ## 19. Source borrow returns
|
||||
docs/spec/15-source-language.md :: ## 9. Frame storage, borrow scopes and features
|
||||
docs/spec/03-memory-model.md :: ## 3. Safe-reference aliasing rule
|
||||
docs/spec/03-memory-model.md :: ## 4. Borrow lifetime
|
||||
|
||||
Reference in new issue
Block a user