Re:Why developers should be force-fed state machines
by pygy_ on Monday June 13, 2011 @01:32PM
(#2649866)
In languages with first class functions and hash tables, you can use this instead (here in Lua):
Much cleaner (even though the Lua syntax for function literals is a bit heavy. It would look much nicer in CoffeeScript...).
[ Parent
| on HN ]
Re:Why developers should be force-fed state machines
by justincormack on Tuesday June 14, 2011 @07:03AM
(#2652521)
Yeah, state as functions is really nice, but it gets messy in languages that don't have tail recursion elimination (eg Javascript), as you have to have a trampoline mechanism to call the next state, I generally return the new state function and get the trampoline to call it. Which is less readable then just calling the new state as in your Lua example...