Higher order receieve anybody

Thomas Lindgren thomasl_erlang@REDACTED
Sat Feb 21 22:48:56 CET 2004


--- 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.

However, to grouch a bit, I'd say receive F end seems
like tinkering. I'd prefer something with more oomph.
(Likewise for !!. And probably structs as well.)

> How about replacing ! with erlang:send/2?

Nowadays, my code tends to use gen_server:call/2 and
suchlike, so I wouldn't mind. Much.

Best,
Thomas


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools



More information about the erlang-questions mailing list