<p dir="ltr">Btw, a, b are atoms which can't be added, no?</p>
<div class="gmail_quote">On 17 Nov 2014 22:46, "Steve Vinoski" <<a href="mailto:vinoski@ieee.org">vinoski@ieee.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 17, 2014 at 4:38 PM, <span dir="ltr"><<a href="mailto:arif@riseup.net" target="_blank">arif@riseup.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have the simplest of applications that consists of just the skeleton gen_server, registered locally as "server", with one callback implemented:<br>
<br>
handle_info({From, A, B}, State) -><br>
From ! {self(), A + B},<br>
{noreply, State};<br>
<br>
i.e. a simple adder<br>
<br>
The supervisor is the skeleton one_for_one supervisor. The application, app, the skeleton application.<br>
<br>
Here is what I do:<br>
<br>
7> application:start(app).<br>
ok<br>
8> server ! {self(), 1, 2}.<br>
{<0.32.0>,1,2}<br>
9> receive X -> X end.<br>
{<0.62.0>,3}<br></blockquote><div><br></div><div>Here you bind X to the tuple value consisting of the server pid and the value 3.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
10> server ! {self(), a, b}.<br>
<br>
=ERROR REPORT==== 17-Nov-2014::22:18:42 ===<br>
** Generic server server terminating<br>
** Last message in was {<0.32.0>,a,b}<br>
** When Server state == {state}<br>
** Reason for termination ==<br>
** {badarith,[{server,handle_<u></u>info,2,[{file,"server.erl"},{<u></u>line,98}]},<br>
{gen_server,handle_msg,5,[{<u></u>file,"gen_server.erl"},{line,<u></u>599}]},<br>
{proc_lib,init_p_do_apply,3,<br>
[{file,"proc_lib.erl"},{line,<u></u>239}]}]}<br>
{<0.32.0>,a,b}<br>
11> server ! {self(), 3, 4}.<br>
{<0.32.0>,3,4}<br>
12> receive X -> X end.<br>
<br>
and here the shell blocks.<br></blockquote><div><br></div><div>It blocks because you're asking to receive the value of X you bound earlier, which doesn't match what's in the mailbox.</div><div><br></div><div>--steve</div></div></div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div>