[erlang-questions] Message queue reflection (was: My biggest beef with Erlang)

David Hopwood <>
Tue Nov 27 17:50:17 CET 2007


Joe Armstrong wrote:
> Now you mentioned receive it occurred to me that it would be rather nice to
> receive a fun in Erlang. Unfortunately receive has only one syntactic form
> 
>      receive
>          pattern1 -> action1;
>          ...
>      end.
> 
> In the spirit of funs it would be very nice to say:
> 
>      F = fun(Pattern1) -> Actions1
>                (Pattern2) -> Actions2
>                after Time -> Actions
>            end,
>      ...
>      receive(Fun)
> 
>       This would make writing an erlang meta interpreter much easier
> and allow all kinds of mischief

The missing feature that is needed to implement this (and lots of other
useful things) is the ability to reflect on a process' message queue.
That is, to iterate through messages in a process' queue without
removing them, and then to remove a given message (rather than just
the first message that matches a statically determined pattern).

-- 
David Hopwood



More information about the erlang-questions mailing list