2 ms·
> I wonder if, at the end of the day, coroutines are fundamentally incompatible with the notion of a stack Well it is with stackless coroutines (by definition)
by duped 5y ago
> I wonder if, at the end of the day, coroutines are fundamentally incompatible with the notion of a stack
Well it is with stackless coroutines (by definition) but they are a kind of state machine. Without a stack or heap as an escape hatch they are quite limiting (as in they aren't Turing Complete by themselves). Stackful coroutines are much more powerful and give you pretty much every kind of control flow you need (while still being strictly less powerful than continuations).
It is possible for a compiler to detect whether a coroutine should be stackless or stackful, in principle at least.