This has always felt like the kind of thing we could be building compilers to solve. Recursive -> explicit stack is a very mechanical conversion, why can't we write a compiler transform pass that does that rewrite any time it detects a high potential for stack overflow?
Jaxan•15m ago
Many compilers do change a recursion into a loop, avoiding the stack altogether!
Epa095•37s ago
Yeah, tail call elimination, is definitely doable.
Python famously does not have it because "Language inventor Guido van Rossum contended that stack traces are altered by tail-call elimination making debugging harder, and preferred that programmers use explicit iteration instead".
https://en.wikipedia.org/wiki/Tail_call
swiftcoder•1h ago
Jaxan•15m ago
Epa095•37s ago
Python famously does not have it because "Language inventor Guido van Rossum contended that stack traces are altered by tail-call elimination making debugging harder, and preferred that programmers use explicit iteration instead". https://en.wikipedia.org/wiki/Tail_call