Erlang Code Replacement
Erlang supports change of code in a running system. Loading a code is handled by code server, just load a module by:
1 rpc:call(NodeName, code, load_file, [Module]).
when you are calling from another, existing erlang node. After this action both current (loaded) and old code are valid. The difference is that exported functions in old code are unavailable. Hence there is no way to make a global call to an exported function in old code, but old code may still be evaluated because of processes lingering in it. To change from old code to current code, a process must make a fully qualified function call. HowTo example is available.
So, the new introduced experimental feature in erlang R13B03:
The -on_load() directive names a function that should be run automatically when a module is loaded:
12345 -on_load(run_me/0).run_me() ->%% do somethingtrue.
The function must return true if the module is to be remained loaded and be callable, or false if the module is to be unloaded.