[erlang-questions] eep: multiple patterns

Dave Peticolas dave@REDACTED
Thu May 29 22:23:50 CEST 2008


Ulf Wiger wrote:
> Richard A. O'Keefe skrev:
>>
>> On 28 May 2008, at 7:41 pm, Ulf Wiger (TN/EAB) wrote:
>>> I would just like to point out, for the record, that
>>> this style of programming works well for gen_server-style
>>> processes (and is, in fact, used in e.g. gen_server.erl),
>>> but for selective receive, it is much harder, since
>>> selective receive relies entirely on pattern matching,
>>> and as such, is very difficult to modularize.
>>
>> It's not completely clear to me what Ulf Wiger means by
>> "this style of programming".  Using "this style of
>> programming" to mean "the decision table pattern",
>> it works perfectly fine for selective receive.
>
> Apologies for being unclear.
> It seemed to me as if the thread was approaching
> the idea of
>
> receive Msg ->
>    case classify_msg(Msg) of
>      Type -> Action
>      ...
>    end.
>
> which is what I was referring to.
> It is not surprising that the OTP behaviours gen_server
> and gen_fsm both use FIFO message reception, and then
> classify each message, sometimes using a callback.
>
> Maybe it's another thread altogether, but, I was
> under the impression that abstract patterns could
> actually help this situation (too) somewhat.
> My own impression is that this is a more pressing
> problem to solve than making multiple patterns more
> convenient. If the discussions are orthogonal, great,
> but otherwise, I'd like to see this particular
> problem considered as well.

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.

thanks,
dave




More information about the erlang-questions mailing list