[erlang-questions] eep: multiple patterns

Ulf Wiger (TN/EAB) <>
Thu May 29 23:21:29 CEST 2008

Dave Peticolas skrev:
> Could you expand on this point for the benefit
 > of the newbies? :)
> I'm not clear about what exactly is the problem
 > with gen_server's message handling and what the
 > better approach is.

The problem is not with gen_server, which is wonderful
for implementing client-server patterns.

The issue is with FIFO message handling, at least when
used for complex state machines. It is very difficult
to write a behavior that lets the user have control
over selective message reception. In selective receive,
you can use only patterns and guards, and neither can
be extended with user-defined logic via a callback

Here are some slides from EUC 2005 on the topic:

You could read the thread:
"plain_fsm - for beginners and purists"
from 2004:


and then the "higher-order receive anybody" thread:


This most likely give you more detail than you asked for. (:

Ulf W

More information about the erlang-questions mailing list