News for hackers. Stuff that matters.
Re:State Machines in Go by JulianMorrison on Sunday February 10, 2013 @04:34PM (#5198011)
The reason I didn't do that is a function from state to state is pure in a functional programming sense as well as being simple, free from virtual dispatch and indirection, and thus fast. It's also easy to harness for testing, because it's side effect free and stateless.

If you wanted to extend it to perform actions on state change, I'd extend the return values to (State, Action, error) where Action is "type Action int" as well, and use the Action in another switch. Thus you are free to pick which actions you care about, and test the actions separately from the state engine.

There are no comments on this comment yet.