JavaScript module files are detected by the extension “.mjs”. They are loaded asynchronously and dynamically by using the JavaScript function import().The convention is currently that after loading the file, the Dogelog player will call a main() function of the loaded script, which needs to be exported. This leads to the following idiom:
Example:import {add, make_special,
...} from "../nova/core.mjs";
...
export function main() {
add("<name>", <arity>, make_special(<func>));
...
}
In the above the native API is made visible through some import. The native API is then used to register some special function by predicate indicator. The idea is that loaded scripts have exactly these side effects and do extend the Prolog interpreter by new functionality. The Dogelog player can undo register through its rollback mechanism.