Section "py"

Python source files are detected by the extension “.py”. They are loaded asynchronously and dynamically by using the Python library importlib.import_module and asyncio.to_thread. 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 present. This leads to the following idiom:

Example:
from nova.core import (add, make_special,
...)
...
def main():
add("<name>", <arity>, make_special(<func>))
...

In the above the native API is made visible through some from import statement. 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.

Kommentare