Design decisions

76. range: on std.seq.{reverse, rotate_left, rotate_right} (debt) and scan_in_place (2026-11-21)

  1. Keep range: ?Range<Int> = none on std.seq.{reverse, rotate_left, rotate_right} as temporary debt until core supports mutable slice views.
    • Reason: The coherent spelling for in-place subrange operations (reverse, rotate_left, rotate_right, sort, fill) is a mutable slice receiver (xs[l..r].reverse()), with no per-method range: option. Decision 61's ListView is strictly read-only across all four compiler crates (view_readonly in cpl-check/lends.rs, not a Place in cpl-ir, immutable Rc<Vec<Value>> in cpl-interp, const T* in cpl::View<T>), and mutable slices also require distinguishing fixed-length slice receivers from growable List<T> (push/pop). Filed as Area: core friction in research/frictions/cf2207h3.md.
    • Reverse: Once core lands mutable slice views, rewrite reverse(mut xs, range: r) / rotate_*(mut xs, k, range: r) to xs[r].reverse() / xs[r].rotate_*(k) via a cpl fix lint and drop the range: parameter.
  2. Add scan_in_place<T>(mut self: List<T>, f: (T, T) -> T) and suffix_scan_in_place<T>(mut self: List<T>, f: (T, T) -> T) to std.seq; codify _in_place naming rule and log [D]T receiver debt.
    • Reason: In-place prefix/suffix scans over a growing List had no allocation-free, lint-clean spelling (for i in 1..a.len: a[i] += a[i - 1] trips L0414, while scan allocates a fresh copy every call). Adopted by proto/ports/ecnerwala/cf2187f2.cp.
    • Naming: Logged in plan/STDLIB.md §2 ("Mutator vs copy twins"): where mutation is the default, the mutator owns the bare verb and the copy takes the participle (sort/sorted); where the pure copy already owns the established verb (scan, suffix_scan), the zero-allocation mutating twin uses _in_place.
    • Debt ([D]T) — resolved: All length-preserving in-place sequence mutators (scan_in_place, suffix_scan_in_place, reverse, rotate_left, rotate_right, nth_element, next_permutation, prev_permutation, and std.rand.Rng.shuffle) now use the built-in IndexedMut trait (is_indexed_mut() + zero-based set_at(i, x) / swap_idx(i, j)), covering List<T>, 1D [D]T (nominal, range, and cut domains), and Str with one signature and no per-type overloads. Mutable slice views remain tracked in research/frictions/cf2207h3.md #1b and will plug into is_indexed_mut() automatically once core adds them.
    • Reverse: Remove scan_in_place and suffix_scan_in_place from stdlib/seq.cp and plan/STDLIB.md, revert the §2 naming rule, and restore ends = scan(ends, (x, y) => x + y) in cf2187f2.cp.