erlang

Erlang Code Replacement


I've created a simple module:

-module(check). 
-export([check/0]). 
check() ->
    Val = 1,
    io:format("Value = ~p~n",[Val]).

Code compiled with erlc. Now let's run Erlang:

Erlang R14B (erts-5.8.1) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.8.1  (abort with ^G)
1> check:check().
Value = 1
ok

If I modify the code, change Val to 2, and compile with erlc, I would expect that check:check will return 2, but this is not the case:

2> check:check().
Value = 1
ok

We get the same result. Even if I restart the shell.

How could I force Erlang to reload module without killing the Virtual Machine?


Solution

  • After you recompile your module, just run, from the shell:

    > l(check).
    

    That will reload the new module and you will be ready to go.