<div dir="ltr"><div class="gmail_extra">I think there is a detail that does not square.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Take this example[*]:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div style="color:rgb(51,51,51);background-color:rgb(253,246,227);font-family:Hack;font-weight:normal;font-size:12px;line-height:18px;white-space:pre"><div><span style="color:rgb(51,51,51)">-</span><span style="color:rgb(133,153,0)">module</span><span style="color:rgb(51,51,51)">(</span><span style="color:rgb(38,139,210)">foo</span><span style="color:rgb(51,51,51)">).</span></div><div><span style="color:rgb(51,51,51)">-</span><span style="color:rgb(133,153,0)">export</span><span style="color:rgb(51,51,51)">([</span><span style="color:rgb(38,139,210)">start</span><span style="color:rgb(51,51,51)">/</span><span style="color:rgb(211,54,130)">0</span><span style="color:rgb(51,51,51)">]).</span></div><br><div><span style="color:rgb(38,139,210)">start</span><span style="color:rgb(51,51,51)">() </span><span style="color:rgb(133,153,0)">-></span></div><div><span style="color:rgb(51,51,51)">    </span><span style="color:rgb(38,139,210)">self</span><span style="color:rgb(51,51,51)">() </span><span style="color:rgb(133,153,0)">!</span><span style="color:rgb(51,51,51)"> </span><span style="color:rgb(203,75,22)">matched_by_b</span><span style="color:rgb(51,51,51)">,</span></div><div><span style="color:rgb(51,51,51)">    </span><span style="color:rgb(38,139,210)">self</span><span style="color:rgb(51,51,51)">() </span><span style="color:rgb(133,153,0)">!</span><span style="color:rgb(51,51,51)"> </span><span style="color:rgb(203,75,22)">matched_by_a</span><span style="color:rgb(51,51,51)">,</span></div><div><span style="color:rgb(51,51,51)">    </span><span style="color:rgb(38,139,210)">a</span><span style="color:rgb(51,51,51)">(),</span></div><div><span style="color:rgb(51,51,51)">    </span><span style="color:rgb(38,139,210)">halt</span><span style="color:rgb(51,51,51)">().</span></div><br><div><span style="color:rgb(38,139,210)">a</span><span style="color:rgb(51,51,51)">() </span><span style="color:rgb(133,153,0)">-></span></div><div><span style="color:rgb(51,51,51)">    </span><span style="color:rgb(133,153,0)">receive</span></div><div><span style="color:rgb(51,51,51)">        </span><span style="color:rgb(203,75,22)">matched_by_a</span><span style="color:rgb(51,51,51)"> -></span></div><div><span style="color:rgb(51,51,51)">            </span><span style="color:rgb(38,139,210)">io</span><span style="color:rgb(51,51,51)">:</span><span style="color:rgb(38,139,210)">format</span><span style="color:rgb(51,51,51)">(</span><span style="color:rgb(42,161,152)">"matched by a/0</span><span style="color:rgb(203,75,22)">~n</span><span style="color:rgb(42,161,152)">"</span><span style="color:rgb(51,51,51)">),</span></div><div><span style="color:rgb(51,51,51)">            </span><span style="color:rgb(38,139,210)">b</span><span style="color:rgb(51,51,51)">()</span></div><div><span style="color:rgb(51,51,51)">    </span><span style="color:rgb(133,153,0)">end</span><span style="color:rgb(51,51,51)">.</span></div><br><div><span style="color:rgb(38,139,210)">b</span><span style="color:rgb(51,51,51)">() </span><span style="color:rgb(133,153,0)">-></span></div><div><span style="color:rgb(51,51,51)">    </span><span style="color:rgb(133,153,0)">receive</span></div><div><span style="color:rgb(51,51,51)">        </span><span style="color:rgb(203,75,22)">matched_by_b</span><span style="color:rgb(51,51,51)"> -></span></div><div><span style="color:rgb(51,51,51)">            </span><span style="color:rgb(38,139,210)">io</span><span style="color:rgb(51,51,51)">:</span><span style="color:rgb(38,139,210)">format</span><span style="color:rgb(51,51,51)">(</span><span style="color:rgb(42,161,152)">"matched by b/0</span><span style="color:rgb(203,75,22)">~n</span><span style="color:rgb(42,161,152)">"</span><span style="color:rgb(51,51,51)">)</span></div><div><span style="color:rgb(51,51,51)">    </span><span style="color:rgb(133,153,0)">end</span><span style="color:rgb(51,51,51)">.</span></div><br></div><br></div><div class="gmail_extra">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 <i>while</i> the expression that matches `matched_by_a` is evaluated. The diagram says `matched_by_b` is not in the mailbox at that point.</div><div class="gmail_extra"><br></div><div class="gmail_extra">But the program terminates, ergo reductio ad absurdum :).</div><div class="gmail_extra"><br></div><div class="gmail_extra">I guess that diagram comes from the algorithm outlined on page 194 of the book. I believe you need to factor in step (5).</div><div class="gmail_extra"><br></div><div class="gmail_extra">Xavier</div><div class="gmail_extra"><br></div><div class="gmail_extra">[*] erlc foo.erl && erl -noshell -run foo</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>