Erlang language issues

James Hague jamesh@REDACTED
Tue Apr 16 20:20:58 CEST 2002


>On a related note, is there a good reason for 'receive' to be a language
>structure, rather than a BIF?  For example, instead of
>
>  receive
>    {foo, X} -> bar(X);
>    {baz, Y} -> quuz(Y)
>  end
>
>couldn't one say, with identical intent,
>
>  Msg = receive(),
>  case Msg of
>    {foo, X} -> bar(X);
>    {baz, Y} -> quuz(Y)
>  end

Ah, but they're not the same!  In the second case you're always pulling a
message out of the mailbox.  In the first case, if the message doesn't match
one of the patterns, then it remains in the mailbox.

I think this is an interesting discussion, one which I unwittingly started
:).  But I suspect that if you wrote down a comprehensive list of the
polluted parts of Erlang (and not just pet peeves about the language
design), it would be a fairly short list.  It might be longer if you include
all of OTP in that list, so junk like the crypto module could get a mention.
This would be a good document to have, I think.



More information about the erlang-questions mailing list