5 ms·
Why not use mutual recursion and TCO? The function with the program counter is the current state. Problem solved? Mutable state is your enemy...
by silentOpen 17y ago
Why not use mutual recursion and TCO? The function with the program counter is the current state. Problem solved?
Mutable state is your enemy...
- silentbicycle 17y agoIt's not always just two coroutines (could be thousands), and not every language has TCO. Also: While mutable state is problematic, sometimes the alternatives are worse.
- silentOpen 17y agoThat's a good point... mutual recursion lacks dynamism. The lack of TCO or ability to do mutual recursion+TCO is really the fault of the language. If you have a state machine with a small number (<20) states, mutual recursion seems like a more natural fit (unless you have to have states determined at run-time).