Higher order receieve anybody

Robert Virding robert.virding@REDACTED
Tue Feb 24 01:10:35 CET 2004

----- Original Message ----- 
From: "Thomas Lindgren" <thomasl_erlang@REDACTED>
To: <erlang-questions@REDACTED>
Sent: Saturday, February 21, 2004 10:48 PM
Subject: Re: Higher order receieve anybody

> --- Robert Virding <robert.virding@REDACTED> wrote:
> > If I understand what you
> > mean then for
> >
> > receive F end
> >
> > you would evaluate F for each message in the queue
> > with the message as
> > argument. If the function returns a value then that
> > message is "received"
> > and receive returns the function return value. If
> > the functions exits then
> > the message is put back in the queue and we go to
> > the next message. Simple.
> Maybe there should just be an operation to reify the
> mailbox (e.g., empty it and make it a list of terms)
> as well as the other way around (e.g., prepend a list
> to your own message queue). Then programmers could
> write receive (with suitable extra operations to code
> after-clauses) any way they liked and provide those as
> library functions.

That would probably be a cleaner way of doing it. Though it would be a
little tricky to handle timeouts. I can't see that there would be real
problems with it, though I will have to think abit.

How much oomph do you want?


More information about the erlang-questions mailing list