[erlang-questions] Pratical solutions for selective send (was: gen_event handler question)

Davide Marquês <>
Wed May 13 16:59:36 CEST 2009


Ahoy! :)

On Wed, Apr 29, 2009 at 9:33 AM, Camille Troillard <>wrote:

>
> On Wed, Apr 29, 2009 at 10:17 AM, Robert Raschke <>wrote:
>
>>
>> > I would like to know if it is possible to write an event handler that
>> would
>> > receive only certain notifications based on a simple criteria.
>>
>> You could use a catch all like handle_event(_, State)-> at the end of
>> your handlers? Not sure if that's the recommended way though.
>>
>
> Yes, I thought about this, hehe.
> But then all the handlers would receive notifications and should decide
> themselves wether or not they should process the message, which is not good.
>  It looks like a design issue on my side, oh well …  maybe this is not the
> "erlang" way to do it …
>
> Cam
>

After reading this I'm wondering... what's the current "erlang way" of doing
selective sends?
Where by "selective send" I mean:
 - a client process sends a "message filter" to a server process;
 - when an event occurs the server checks the client's "message filter" to
determine if a notification should be sent.

Looking for possible implementations for the "message filter" I found these:
 - match_specs (http://erlang.org/doc/apps/erts/match_spec.html)
 - abstract patterns (http://www.erlang.org/eeps/eep-0029.html)
>From what I read the later seems more flexible in that it enables matching
out-of-order elements
(which comes in handy since I'm interested in a "message-based + named
stuff" API).

Are there any solutions in the wild I can take a peek at? :)

Thanks in advance!
:Davide
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090513/e21bf7a9/attachment.html>


More information about the erlang-questions mailing list