September 2013
Intermediate to advanced
548 pages
12h 25m
English
The default mechanism for loading code into Erlang is to use a form of “on-demand” code loading. When code is first called and it is discovered that the code is missing, then the code is loaded.
This is what happens. Assume the function
my_mod:myfunc(Arg1, Arg2, ... ArgN) is called but the
code for this module has not yet been loaded. The system
automatically converts this call into the following call:
error_module:undefined_function(mymod, myfunc, [Arg1, Arg2, ..., ArgN])
undefined_function is something like this:
| | undefined_function(Mod, Func, ArgList) -> |
| | case code:load_module(Mod) of |
| | {ok, Bin} -> |
| | erlang:load_module(Mod, Bin), |
| | apply(Mod, Func, ArgList); |
| | {error, _ } -> |
| | ... |
| | end |
Read now
Unlock full access