Mon Oct 15 10:11:14 CEST 2018
I need a good syntax to implement state machines, but above all, a
better way to think about implementing them.
Often, state machines are too low-level. Nested loops provide a
better mechanism. I want a way to relate the two.
In Seq, a syntax transformation would be easy to implement, so why
can't I just write this down?
- loops: remain in a state as long as condition is not met
- re-use counters, and possibly counter conditions, between states
The trick is in the reuse of resources between states. Having to do
this explicitly is also what makes manual state machines hard to
develop. Using a CPU, the shared resources are the CPU resources
(registers, ALU, instruction sequencer).
So it is the reuse of resources between states that makes things
complicated. Also, state components used in one branch, and not used
in another, still need to be initialized. It is exactly this that a
more "imperative" language would solve: by default, keep value. It
appears it is this property of needing to specify unused values that
gets in the way.