3 ms·
> a way to convert most of my state machine into sequential code Isn't that the norm for state machines in C? while (cont) { switch (v) { case
by microcolonel 7y ago
> a way to convert most of my state machine into sequential code
Isn't that the norm for state machines in C?
while (cont) {
switch (v) {
case S_STOP:
cont = 0;
break;
...
}
}
Or are you talking about inlining sequences of transitions into eachother? I've been avoiding core.async so I don't really know what it does that has to do with this.
- jwr 7y agoWith core.async (or go, for that matter), you can write code like: * do one thing * wait for the result of one thing (for example, an event from an interrupt) * take the result and feed it into another thing * wait for the result of another thing So the code looks sequential. It's easy to write and easy to understand. But the entire 'go' block returns immediately: the whole thing gets converted into a state machine (which you don't normally see). That way you don't have to manage the complexity of the state machine yourself. Note that this is not the same thing as threading. Also, it does not require threading at all, for example core.async works just as well in ClojureScript, even though Javascript has no threads.