Design decisions

9. Approved on 2026-11-20

Ryan approved plan/19-index-and-lends.md: one mechanism for domain, Str, Grid and Perm, and lexical exclusivity as the borrow model.

The design. A bounded index is a sealed struct with impl Index (2.1, 2.15). Indexing is the Indexed trait and [I]T is a library struct (2.15). Slices, rows and element access are projections that lend part of their receiver (5.12), lent values are second-class (5.14), and two lends of the same container are allowed when the projection's disjoint law is proven (5.13). No borrow is ever stored or returned (5.3). Sub<V> is removed (2.4, 2.8). Decisions 3.8, 4.8 and 5.5, which were open, are settled by it.

His three changes.

  • let K = n, not const K = n, for a size frozen from a run-time value. const stays strictly compile-time (3.8, 7.10).
  • v.l / v.r, with v.l(k) / v.r(k), as the short spellings of v.before / v.after (2.2).
  • Char and Str are ASCII only: one byte per Char, a flat [S]Char or List<Char>, and no UTF-8 (1.6).

Also locked in. / and % are Euclidean on integers, and cost nothing when the operands are proven non-negative and positive (1.9).

Prototype. proto/cpc/ implements the surface rules of the above and keeps the 30 corpus ports passing; plan/19-index-and-lends.md §11 lists what it covers and what it leaves out. One call made there and not yet confirmed by Ryan: v.l(k) and v.r(k) count v itself, so v.l is v.l(1).