[erlisp-devel] Re: receiving, pattern-matching
Gerd Flaig
gefla at pond.sub.org
Tue Aug 30 08:34:03 UTC 2005
Faré <fahree at gmail.com> writes:
> What should happen when you receive something that doesn't match any
> pattern? I don't remember what happens in Erlang: either the message
> is dropped or it raises an error, I suppose (gotta read the
> documentation). In Lisp, it could be configurable. See match vs ematch
> just like we have case vs ecase.
unmatched messages are buffered. I've attached a small test module
demonstrating this.
Goodbyte, Gerd.
-module(f).
-export([r/0]).
l() ->
receive
{a,A} ->
io:format('a: ~p~n', [A])
end,
receive
{b,B} ->
io:format('b: ~p~n', [B])
end,
receive
R ->
io:format('r: ~p~n', [R])
end,
l().
r() ->
Pid = spawn(fun l/0),
Pid ! {b, bla},
Pid ! foo,
Pid ! {a, blubb}.
Eshell V5.4.6 (abort with ^G)
1> c("/tmp/f", [{outdir, "/tmp/"}]).
{ok,f}
2> f:r().
a: blubb
{a,blubb}b: bla
r: foo
3>
--
The last thing one knows in constructing a work is what to put first.
-- Blaise Pascal
More information about the Erlisp-devel
mailing list