Design decisions

124. A half-open range of cuts is also the piece it bounds (2026-11-21)

  • Decision. With cuts j, i: D.bounds, j..i is a Range<D.bounds> (iterating it yields cuts). Wherever a Range<D> is expected, it converts implicitly to the positions between cut j and cut i: cost(j..i), pre.sum(j..i), a[j..i], window.move(to: j..i). The two readings are the same set under c ↦ c.right. Every cut in j..i has a right neighbour because i is excluded, and both are stored as the same two integers. j..=i over cuts stays a range of cuts only (its last cut may be the end) and gets no conversion. Constant integer literals are accepted for cut-domain values, checked against the domain's range (var mex: Potential.bounds = 0).
  • Why. DP transitions iterate cuts (for j in lo..i: dp[i] min= dp[j] + cost(j..i)) and pass the piece between them on the same line. A single rule keeps both readings without a cast or a second spelling, and the "ranges are over cuts" model stays exact: a range's ends are cuts, its elements are positions.
  • Rejected. Context deciding what j..i means (one text, two meanings); .. versus ..= choosing the element type; mandatory span(j, i) (honest but noisy on the commonest DP line, and the fallback if the conversion ever surprises reviewers).
  • Reverse. Drop the conversion; call sites use span(j, i).
  • Status. Accepted; not implemented. Blocked first on D.bounds as a value in cpl run / cpl build (E0501).