On Recursion, Continuations and Trampolines
https://eli.thegreenplace.net/2017/on-recursion-continuations-and-trampolines/
Wonderful post with really clear examples, relating TCO and CPS.
miniblog.
Related Posts
Every time I implement an interpreter with recursion, I regret it.
As soon as I want TCO, or userland control of stack limits, or resumable exceptions, I need my own stack.
This is awkward because it's an upfront design decision. Changing the stack model is a big refactoring.
Clippy has a ton of clever lints I haven't seen before.
E.g. it suggests that `let _v = println!("hello");` could be `println!("hello");` because a variable of type () is pointless.
Warning about recursion in main is an excellent idea too.
Scheme and Common Lisp are much more different than I realised.
They have very different error handling models, object systems, approaches to documentation (e.g. use of docstrings), not to mention conventions on iteration, recursion and early termination.