[eeps] Match specs and receive

Andras Georgy Bekes bekesa@REDACTED
Wed Aug 6 18:15:10 CEST 2008


On Friday 11 July 2008, Richard A. O'Keefe wrote:
> Fredrik Linder asked about the possibility of
>         receive MatchSpec(X) -> ...
> and
>         function(MatchSpec(X) = V) -> ...
>
> get something that compiles 
> a MatchSpec to a recogniser 'fun' (or a receiver 'run').
>
> This may well be _better_ than putting it in the syntax,
> because it lets you use compiled (with HiPE, even native-
> compiled) code rather than interpreting MatchSpecs.
I don't know what Fredrik would use these receiver fun's, but I think 
your proposal lacks something that his can do.

With his proposal I could (just for example) write a gen_server variant 
that does not have to accept each message as they arrive, but can 
effectively do selective receive.

For example, if the handle_call function in the callback module returns
{reply, Reply, NewState, MessageSpec}

then the behavior module could receive only the "interesting" messages 
and leave everything else on the message queue, while it could, --- at 
the same time --- receive system messages, etc. as well.

So the point is that if matchspecs are allowed in receives, then they 
can be combined with "normal" patterns and with other matchspecs.

	Georgy



More information about the eeps mailing list