Design decisions

11. Leaning since 2026-11-20: the ergonomics audit

A read of all 30 ports as code (research/archive/audits/ergonomics-audit.md) changed the prototype in the ways below. They are implemented in proto/cpc/, eleven ports use them, and crates/cpl-cli/tests/cases/ergo/ locks them. None is confirmed by Ryan yet, so each is Leaning. Per the rules at the top of this file, each says what is library code and what is not.

  • The optional step (2.9, revised). i + k and i - k on a position are a ?I. In the library this is impl Add<Int> on any Seq, the body of the offset that 12 §1.3 already had. It revises a settled row: v + 1 was an error. The reason is the six ports that did the step on raw .idx with a separate guard; the step can still never produce a position outside the domain.
  • if let a = x and let b = y. Syntax. It extends the existing if let a = x and cond, so two optional steps need no nesting.
  • Open ranges ..i, ..=i, i... Syntax: a range literal may omit an end, and takes its type from the end it has. Range<I> is the library struct of plan/19 §4.1.
  • A boundary may end a range. Library: Range<I> is two Bounds<I>, so ..b and b.. are the cells before and after boundary b. ..=b is an error.
  • span(a, b), r.prefix(k), r.suffix(k), b.left, b.right. Library functions and methods on Range and Bounds; left and right are already in plan/19 §4.1.
  • Code after a lend (write-back). Already designed in plan/19 §3.4; now prototyped. It is what lets a container keep a derived value right on every write.
  • Counter<K> and counts(xs). A library struct whose at is a projection with a write-back; crates/cpl-cli/tests/cases/lend/writeback.cp is that struct in .cp. The prototype compiles it in, as it does SegTree.
  • prefix(a) with pre.sum(range) / pre.sum(rows, cols). A library struct over [I.bounds]T, compiled in for the same reason.
  • x f= y for any two-argument fn. Syntax, and one rule in place of two: min= and max= are now instances of it.
  • [domain S]Letter = read(). Library: read for an array whose element is a domain of Char.