main-stubbed-functions.md
AtomVM implements stub functions for certain BEAM operations that are either not applicable to embedded environments, not yet implemented, or intentionally left as no-ops for compatibility reasons. These functions allow BEAM code that references them to load and execute without errors, even though the actual functionality may not be present.
Stubbed functions serve several purposes in AtomVM:
Compatibility : Allow BEAM modules that use these functions to work anyway
Environment Differences : Functions that make no sense in embedded contexts (or in AtomVM) but are required for code compatibility
Performance : Operations that would be too expensive on microcontrollers and are safely ignored
The following functions are currently stubbed in AtomVM and always return a fixed value:
|
Module
|
Function
|
Return Value
|
Notes
| | --- | --- | --- | --- | |
io
|
set_ops/1,2
|
ok
|
Standard IO options are currently ignored
|
|
Module
|
Function
|
Return Value
|
Notes
| | --- | --- | --- | --- | |
string
|
jaro_similarity/2
|
0.0
|
|
When using AtomVM, be aware that stubbed functions will not provide the functionality you might expect from BEAM. Code that relies on these functions for critical behavior will need to be adapted for the AtomVM environment.
To write portable code that works on both BEAM and AtomVM, you can detect the runtime environment:
case erlang:system\_info(machine) of"BEAM" -\>%% Use full functionalityfull\_implementation();"ATOM" -\>%% Use alternative approach or skipalternative\_implementation()end
Some stubbed functions may be implemented in future versions of AtomVM. Use GitHub issues for providing any kind of feedback.