// Constructed product results (issue #200, ADR 0043): a tuple-returning // helper whose result a caller destructures goes through a worker that // returns the components, so the tuple is never built on that path. import std/io // Deliberately branchy so the simplifier won't inline it (CPR's case, // not inlining's). fn splitmix :: x: Int -> (Int, Int) { if x == 0 { (0, 0) } else { if x == 1 { (1, 2) } else { if x == 2 { (3, 4) } else { if x == 3 { (5, 6) } else { if x == 4 { (7, 8) } else { (x * 3, x * 5) } } } } } } fn go :: n: Int acc: Int -> Int { if n == 0 { acc } else { let (a, b) = splitmix (n % 7) go (n - 1) (acc + a + b) } } pub fn main :: -> () / { io.println (show (go 1000 0)) // Kept whole, not destructured: the wrapper path still builds a tuple. let whole = splitmix 6 io.println "whole: {whole:?}" } //> 17732 //> whole: (18, 30)