[erlang-questions] hot-code replacement

jces@REDACTED jces@REDACTED
Tue Oct 17 04:41:42 CEST 2006


>can anyone tell me in detail about the hot-code replacement feature in 
>erlang and how it works... Also i am a bit confused if this feature is 
>inherent to erlang or implemented just as a added function..

Hello,

I recently learned about it and used it; use the fully qualified name of
the function in the tail-recursive-call "module:function()" rather than
simply "function()". Then, to go even further, you can use
"?MODULE:function()" so that you can change the module name any time, I
guess. That ends up with something like:

-module(test).
-export([start/1]).
start(Arg) ->
    receive
	finished ->
	    io:write(Arg);
	not_finished ->	   
	    ?MODULE:start(Arg+1)
end.

(lerl@REDACTED)1> c("src/test", [{outdir, "/src/"}, debug_info]).
{ok,test}
(lerl@REDACTED)2> Pid = spawn(test,start,[1]).
<0.44.0>
(lerl@REDACTED)3> Pid!not_finished.
not_finished
(lerl@REDACTED)4> Pid!finished.
2finished
(lerl@REDACTED)5> 




More information about the erlang-questions mailing list