Module code

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

Function Index

ensure_loaded/1 Try to load a module if it's not already loaded.
load_abs/1 Load a module from a path.
load_binary/3 Load a module from a binary.

Function Details

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.

load_abs/1


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

Filename: path to the beam to open, without .beams 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.