Design decisions

127. Recursive lambdas; no method overloading (2026-11-21)

  • Decision. A lambda bound with let may 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 =>). A var binding cannot refer to itself. Recursive lambdas and recursive nested fns lower to a self-passing generic C++ lambda, never std::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 in plan/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 fn only), or allow method overloads with a resolution rule.
  • Status. Accepted; recursive lambdas not implemented (today they fall back to std::function, decisions around DynamicStdFunction).