Design decisions

144. One ownership model, written out with exercises (2026-11-21)

  • Decision. spec/core/05-ownership.md states the whole model as rules R1 to R12 and wins over older text. It settles: .clone() is the copy; no mut fn (5.10); push-only generators (126); plain means "no heap part"; a read lend forbids writes, not only resizes; lent values may sit in a var, field or container that dies no later than their sources (relaxes 5.14 and 141 rule 3, so var st = SegTree(V, op: closure over ws) works); lent structs can be built anywhere; closure captures are borrowed per call; 5.4's reuse of a callee's mut borrow by an inline closure is withdrawn; let p = mut a[i] is allowed; let row = rows[i] on a heap element is a read lend (at is a lends fn). Assignments run the right side, then the target's indices, then the write, so a[l] += inc(mut a[l]) and xs[0] = xs.pop()! compile, both linted (a lint, not a ban, for legal but easy-to-misread code), reversing plan/19 red-team case 15.
  • Why. Ryan asked for one document from which any snippet can be judged at a glance; the older documents disagreed on these points.
  • Reverse. Restore 141 rule 3 (lent values only in lets), or hold closure captures for the closure's life.