3 ms·
Coroutines are potentially-infinite state machines, not finite state machines. While their instruction pointers belong in a finite state space, their usable mem
by mehrdadn 8y ago
Coroutines are potentially-infinite state machines, not finite state machines. While their instruction pointers belong in a finite state space, their usable memory space is infinite.
- defanor 8y agoI've spent some time thinking how to put it, but it indeed doesn't seem like equivalence -- perhaps more of an inclusion. Or coroutines should be limited to stateless ones, but then a similar statement could be made about regular subroutines. Though not even sure what would be a proper way to compare state machines to coroutines, maybe some context is missing.
- deleted 8y ago[deleted]
- RossBencina 8y agoIn addition to state, coroutines can also have side effects. So you kinda need effectful, stateful "finite" state machines to get started.
- raxxorrax 8y agoWhat is the difference between a side effect and a state transition?
- RossBencina 8y agoA side effect would do something external to the state machine, such as transmit something on the network, or perform disk i/o. Or it might emit an event that is received by another concurrent state machine.
- rumcajz 8y agoWhile that's true in theoretical sense, what we call "state machines" in the real world do have additional state. For example, TCP state machine has CWND. The same way, coroutines allow for additional state.
- mehrdadn 8y agoIn the article he says "finite state machines", not merely "state machines". The distinction is not negligible. FSMs have important properties (and corresponding algorithms) that rely on the fact that their state spaces are finite.
- defanor 8y agoThe article's aim is said to be to clarify the meaning of that, but it still seems confusing: if it's rather informal, perhaps it is worth linking the mentioned examples that refer to this equivalence. Sounds like it makes sense in some context, but evidently it may be hard to make sense of it otherwise.