Big state machines

Ulf Wiger ulf@REDACTED
Sat Apr 23 11:16:21 CEST 2005

Den 2005-04-23 08:50:47 skrev Ulf Wiger <ulf@REDACTED>:

> Or was it perhaps because I hadn't
> documented the option of skipping the parse transform and
> writing more or less the way you did?

Hmm, re-reading the plain_fsm documentation, I see that
this wasn't entirely correct:

"In the states where you want to handle system messages, you
have two choices:

(A) Insert the system messages in the receive clause:

   idle(S) ->
      Parent = plain_fsm:info(parent),
         {system, From, Req} ->
                  From, Req, S, fun(S1) -> idle(S1) end);
         {'EXIT', Parent, Reason} ->
            plain_fsm:parent_EXIT(Reason, S);
         ... %% your original code here

This has the advantage that everyone can understand what's going on.
The part that plain_fsm.erl helps you with is the set of functions
system_code_change(), system_continue(), system_shutdown(),
format_status(), which are required callbacks when you handle
system messages directly."


It seems as if the ?SYSTEM and ?EXIT macros should be possible
to build on top of this framework as well.


More information about the erlang-questions mailing list