Modules API
Modules Resolution is a process of finding out which modules should be preloaded for a correct compilation of a given module.
Resolution expected to use bind_module, modules_require as an input and produce results in form of modules_resolution data table.
Module Annotations: 'bind_module'
- module-ref module's path
Declares module annotations.
Example:
module:: status(obsolete).
Produced fact: bind_module("/path/to/module",status(obsolete))
Requesting Modules: 'modules_require'
- module-ref module's path
- request expressed by annotation
Module can request other modules necessary for correct work. Declared requests can be processed to find a resolution.
Example:
module { require(logger). }
Produced declaration: modules_require("/path/to/module", logger)
Modules Resolution: 'modules_resolution'
- request expressed by annotation
- module-resolved-ref resolved module's path
- module-context-ref context module's path
Xreate uses the data table to find correspondent modules for each request.
Form (1) assigns resolved module to a request and assumes that assignment is valid in all cases, i.e. whenever compiler encounters request it loads associated module.
Form (2) assigns resolution valid only in a specific context. Compiler uses particular resolution only for requests that came from a module specified in a context. In other words, form (2) allows to resolve the same request differently for different modules depending on resolution strategy, thus implementing polymorphism on module level.
See Also
Syntax: Modules