Erlang language issues

Chris Pressey <>
Wed Apr 17 00:40:09 CEST 2002


On 16 Apr 2002 23:12:55 +0200
Luke Gorrie <> wrote:

> "Chris Pressey" <> writes:
> 
> > >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.
> > 
> > Good point.  A more accurate analogy would be
> > 
> >   Msg = receive(),
> >   case Msg of
> >     {foo, X} -> bar(X);
> >     {baz, Y} -> quuz(Y);
> >     _ -> putback(Msg)
> >   end
> > 
> > And at that point, it's hard to see how this is any better than the
> > built-in receive language structure.  In fact it's arguably worse, as
> > it's quite easy to forget to put the message back...
> 
> It needs to do more still - receive scans the whole queue for a
> message that matches the pattern, and if it finds one then removes
> only it. If there isn't a match it has to block until new message(s)
> are received, and then scan those with the same patterns.
> 
> And do timeouts :-)
> 
> Cheers,
> Luke

OK - then it's easy to see why it's a language feature.

Guess I should've figured that out myself... :)

Chris



More information about the erlang-questions mailing list