Design decisions

73. Flip<T> / flip_action in std.lazy, combinator devirtualization, and LazyTreap fast path (2026-11-21)

  1. Add Flip<T> (Flip.of) and flip_action<T, M>(m) to std.lazy. Encapsulates the paired-complement range-toggle pattern ((now, flipped) with Bool XOR tag) for any monoid m with zero compiler privilege. Adopted by proto/ports/ecnerwala/cf2152g.cp (387 -> 280 tokens, 1.27x of dream; 35,469 -> 30,720 B emitted). Reverse: remove Flip and flip_action from stdlib/lazy.cp and restore the hand-rolled Action in cf2152g.cp.
  2. Treat closures whose captures are only used as StaticDirect callees as captureless in cpl-codegen. In crates/cpl-codegen/src/devirt.rs, a closure that captures a Monoid or Action solely to invoke its StaticDirect op/apply/compose field has zero live captures in emitted C++, so it lowers to a top-level static auto cpl_fnN (emitted in dependency order in emit.rs) with zero std::function. Gives 0 std::function on flip_action (cf2152g: 8 static direct, 0 dynamic) and any user-written Monoid/Action combinator. Reverse: restore captures.is_empty() in devirt.rs.
  3. Avoid sibling cache misses and tagless pushdown calls in LazyTreap.ins / split_val. Increment nodes[i].sz directly on descent in ins and guard push_tag with if let f = nodes[i].tag: in ins/split_val, bringing bench/ranges/lazy_treap from 111.9 ms (1.34x) down to 85.8 ms vs 81.1 ms matched C++17 (1.06x). Reverse: restore down/pull calls in stdlib/lazy.cp.