<br><br><div class="gmail_quote">On Feb 2, 2008 2:46 AM, Balu Balasubramanian <<a href="mailto:avbalu@hotmail.com">avbalu@hotmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Thanks, Bengt.<br>Makes sense. Yes, the shell did crash and got recreated with new process id. But I see that the variable binding for G is still valid.<br>That raises one more question (not really related to digraph)<br>
When the shell (and in general any process) crashes won't it automatically forget the variable bindings as well?</blockquote><div><br>There is big difference between shell and any other process in normal working application. Shell itself is one process which keep variable binding different way than normal bindings in normal functions (and so variables are binded only inside functions, not for whole process).<br>
When you type some expression, expression is evaluated inside different subprocess and this subprocess is reused until crash. When evaluating subprocess crash, new one is created and used since that moment. Because bindings are kept inside shell main process, they can survive evaluating process crash. So behavior of shell is different from behavior of normal processes. For example digraph:new is called from evaluating shell process and digraph made they own ets tables with PID of evaluating process stored. Then result graph object is saved in shell main process and when evaluating process crash, graph disappear but graph record inside main shell process binding storage don't. Shell only emulate variable bindings inside one function this way. Shell can be made different way using try - catch but there is other caveats. For example you would be able break shell main process from evaluating expressions. (You can do it anyway in present implementation by code loading and storing code reference in shell bindings.)<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br><br>----------------------------------------<br>> From: <a href="mailto:bengt.kleberg@ericsson.com">bengt.kleberg@ericsson.com</a><br>
> CC: <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>> Date: Tue, 29 Jan 2008 09:52:55 +0100<br>> Subject: Re: [erlang-questions] Question on Diagraph module<br><div><div></div><div class="Wj3C7c">
><br>> Greeteings,<br>><br>> Presumably you are getting the error because G is gone.<br>><br>> I have never used digraphs but the manual page<br>> (<a href="http://erlang.org/doc/man/digraph.html" target="_blank">http://erlang.org/doc/man/digraph.html</a>) says:<br>
><br>> "The digraph will, however, be deleted if the process that created the<br>> digraph terminates."<br>><br>> Your shell process, that created G, has just crashed.<br>><br>><br>> bengt<br>
><br>> On Tue, 2008-01-29 at 08:16 +0000, Balu Balasubramanian wrote:<br>>> Hi,<br>>><br>>> I am new to Erlang!<br>>><br>>> Can some one explain why I am getting the last error message (badarith) that I get with digraph module in stdlib.<br>
>><br>>> Erlang (BEAM) emulator version 5.5.4 [source] [64-bit] [async-threads:0] [kernel -poll:false]<br>>><br>>> Eshell V5.5.4 (abort with ^G)<br>>> 1> G=digraph:new().<br>>> {graph,14,15,16,true}<br>
>> 2> digraph:info(G).<br>>> [{cyclicity,cyclic},{memory,847},{protection,protected}]<br>>> 3> digraph:info().<br>>><br>>> =ERROR REPORT==== 8-Jan-2008::22:02:06 ===<br>>> Error in process with exit value: {undef,[{digraph,info,[]},{erl_eval,d o_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}<br>
>><br>>> ** exited: {undef,[{digraph,info,[]},<br>>> {erl_eval,do_apply,5},<br>>> {shell,exprs,6},<br>>> {shell,eval_loop,3}]} **<br>>><br>
>> % the above error is obvious as digraph:info/0 is udnefined. But now,<br>>><br>>> 4> digraph:info(G).<br>>><br>>> =ERROR REPORT==== 8-Jan-2008::22:02:08 ===<br>>> Error in process with exit value: {badarith,[{digraph,info,1},{erl_eval ,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}<br>
>><br>>> ** exited: {badarith,[{digraph,info,1},<br>>> {erl_eval,do_apply,5},<br>>> {shell,exprs,6},<br>>> {shell,eval_loop,3}]} **<br>
>><br>>> % Can some one please explain the above badarith error? Are there known issues with the digraph module?<br>>><br>>> 5> init:script_id().<br>>> {"OTP APN 181 01","R11B"}<br>
>> 6><br>>><br>>><br>>> Thanks<br>>> Balu<br>>><br>>><br>>> _________________________________________________________________<br>>> Connect and share in new ways with Windows Live.<br>
>> <a href="http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008" target="_blank">http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008</a><br>>> _______________________________________________<br>
>> erlang-questions mailing list<br>>> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>>> <a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>> _______________________________________________<br>> erlang-questions mailing list<br>> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>> <a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></div></div><div class="WgoR0d">_________________________________________________________________<br>Need to know the score, the latest news, or you need your Hotmail®-get your "fix".<br><a href="http://www.msnmobilefix.com/Default.aspx" target="_blank">http://www.msnmobilefix.com/Default.aspx</a><br>
</div><div><div></div><div class="Wj3C7c">_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br><a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil