127. Recursive lambdas; no method overloading (2026-11-21)
- Decision. A lambda bound with
letmay call itself by its binding name (let fact = n => if n == 0: 1 else: n * fact(n - 1)). It is inferred like any lambda; when the recursion leaves the return type undetermined, the error asks for an annotation ((n: Int) -> Int =>). Avarbinding cannot refer to itself. Recursive lambdas and recursive nestedfns lower to a self-passing generic C++ lambda, neverstd::function. - Decision. Methods do not overload by argument type, like free fns
(see "free fns cannot overload" above). One name has one generic signature; variants are
named arguments (
at:/over:) or protocols. - Rule. Every accepted decision states its C++ lowering and cost. A
std::function, hidden allocation or hidden traversal is logged as debt inplan/DOMAINS.md. - Why. A self-passing lambda is a direct monomorphized call, so
recursive lambdas cost nothing over a nested
fn. Overloads make errors, hover and docs ambiguous, and break one spelling per idea. - Reverse. Forbid self-reference (nested
fnonly), or allow method overloads with a resolution rule. - Status. Accepted; recursive lambdas not implemented (today they fall
back to
std::function, decisions aroundDynamicStdFunction).