Module code

An implementation of a subset of the Erlang/OTP code interface.

Function Index

all_available/0 Return all modules available from loaded avm packs, in addition to loaded modules.
all_loaded/0 Return a list of all loaded modules.
ensure_loaded/1 Try to load a module if it's not already loaded.
is_loaded/1 Determine if a module is loaded.
load_abs/1 Load a module from a path.
load_binary/3 Load a module from a binary.
which/1 Determine if a module is loaded.

Function Details

all_available/0


all_available() -> [{unicode:unicode_binary(), term(), boolean()}]

returns: A list of available modules, including loaded modules

Return all modules available from loaded avm packs, in addition to loaded modules. List of available modules may be incomplete if this function is called while a module is loaded. Result type differs from Erlang/OTP: names of modules is a binary (and not a string), and second term of tuples is currently unspecified

all_loaded/0


all_loaded() -> [{atom(), term()}]

returns: A list of all loaded modules

Return a list of all loaded modules. Result type differs from Erlang/OTP: second term of tuples is currently unspecified

ensure_loaded/1


ensure_loaded(Module) -> {module, Module} | {error, embedded | any()}
  • Module = atom()

Module: module to load

returns: Tuple {module, Module} if module is loaded or {error, embedded}

Try to load a module if it’s not already loaded. AtomVM works in an embedded-like mode where modules are loaded at start-up but modules can be loaded explicitely as well (especially from a binary with load_binary/3). So this function can be used to determine if a module is loaded. It is called by Elixir Code module.

is_loaded/1

is_loaded(Module) -> any()

Determine if a module is loaded. AtomVM works in an embedded-like mode where modules are loaded at start-up but modules can be loaded explicitely as well (especially from a binary with load_binary/3).

load_abs/1


load_abs(Filename::string()) -> error | {module, module()}

Filename: path to the beam to open, without .beam suffix

returns: A tuple with the name of the module

Load a module from a path. Error return result type is different from Erlang/OTP.

load_binary/3


load_binary(Module::module(), Filename::string(), Binary::binary()) -> error | {module, module()}

Module: name of the module to load
Filename: path to the beam (unused)
Binary: binary of the module to load

returns: A tuple with the name of the module

Load a module from a binary. Error return result type is different from Erlang/OTP. Also unlike Erlang/OTP, no check is performed to verify that Module matches the name of the loaded module.

which/1

which(Module) -> any()

Determine if a module is loaded. There currently is no way to distinguish a module that was loaded with load_binary/3 or that was preloaded at startup.