Erlang's FSM code_change function usage <p>I'm learning Erlang and I've learned about hot code loading, but I don't know how the gen_fst behavior's code_change function works. I also can't find any example of it.</p> <p>Should I create an action like so:</p> <pre><code>upgrade() -&gt; gen_fsm:send_event(machine_name, upgrade). </code></pre> <p>And have a handler in the states like so:</p> <pre><code>some_state(upgrade, State) -&gt; code:purge(?MODULE), compile:file(?MODULE), code:load_file(?MODULE), {next_state, some_state, State, 1000}. </code></pre> <p>I've tried this, but the <code>code_change/4</code> function doesn't execute. How should I correctly implement hot code loading in my FSM?</p>