[erlang-questions] eep: multiple patterns

Bjorn Gustavsson <>
Mon Jun 2 09:32:48 CEST 2008

Sean Hinde <> writes:

> You are right.
> I had thought that there was an optimisation where if the pattern was  
> identical to last time the same receive was entered for that process  
> then only newer messages were examined.

No, there is only an optimization within the same receive: if the receive
is waiting because none of the messages in the message queue matched
the pattern, when new messages are sent to the process, only those messages
will be matched.

> Seems like it could be a useful optimisation in any case :-)

Yes, but I think it would be a lot of work in both the compiler and
the run-time system. The trick is to avoid slowing down receives in general
when selective receives are not used.

Björn Gustavsson, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list