Design decisions

326. A fold costs what the receiver's type says (2026-11-22)

Ryan rejected an O(1) special case for (3..m).step(2).sum(). The rule is general: an operation's cost belongs to the receiver's type, through ordinary method resolution. The generic folds (sum, prod, count, min, max, fold, contains, last, nth) are default methods of the capability trait that gives them. A type overrides one in its impl, in CP Lang, with its documented cost: impl Seq for Range gives closed forms, as Prefix.fold is O(1) and Bitset.len is a popcount. R08.1.4 stays as written (inherent methods first, then traits), and generic code calls the receiver's impl, so an override holds through generics (core-08/trait-default-overridden-through-generic.cp, which passes). A free extension function is final: a concrete self: Range<Int> and a generic self: S of one name are E0701. Today the compiler silently picks the generic one (core-08/extension-concrete-and-generic-ambiguous.cp). Parens still mean "may do work" (decision 140). Hover and cpl explain show the resolved method. The compiler's range_sum intrinsic (crates/cpl-ir/src/lower/call.rs try_range_int_sum) goes once std overrides sum on ranges. Lost: compiler pattern matching of pipelines (a privilege user types can't have, and the next fold needs another special case); "most specific self wins" over extension functions (that is specialization: concrete and generic calls on one type would differ). Reverse: allow concrete extensions to shadow generic ones at concrete receivers.