[erlang-questions] How exactly Erlang receive expression works?
Fri Mar 16 15:57:04 CET 2018
I think there is a detail that does not square.
Take this example[*]:
self() ! matched_by_b,
self() ! matched_by_a,
io:format("matched by a/0~n"),
io:format("matched by b/0~n")
According to your (very nice!) diagram, this program should hang, because
when b/0 is invoked, the message `matched_by_b` has already been moved into
the save queue, and b/0 is called *while* the expression that matches
`matched_by_a` is evaluated. The diagram says `matched_by_b` is not in the
mailbox at that point.
But the program terminates, ergo reductio ad absurdum :).
I guess that diagram comes from the algorithm outlined on page 194 of the
book. I believe you need to factor in step (5).
[*] erlc foo.erl && erl -noshell -run foo
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions