This is actually a fascinating example: https://lucywang000.github.io/clj-statecharts/docs/get-start...
... because it highlights precisely my criticism.
;; define the machine
(def machine
(fsm/machine
{:id :lights
:initial :red
:context nil
:states
{:green {:on
{:timer {:target :yellow
:actions (fn [& _]
(println "transitioned to :yellow!"))
}}}
:yellow {:on
{:timer :red}}
:red {:on
{:timer :green}}}
:on {:power-outage :red}
}))
I just ... don't understand why anyone would do it this way. The code itself already says what to do. Adding this sort of data only subtracts from clarity with no additional flexibility.You might argue that the data model makes it flexible. But I look at that and go, that's what a function is for. The only thing you need is `(println "transitioned to :yellow!")` inside of a function called transition-to-yellow, or if you're feeling adventurous, a function called transition-to which takes yellow as an argument.