| |||||||||||
| A clear mechanism to structure large programs, the MINERVA packages allow to
MotivationLarge programs, teams of several programmers, maintenance needs and software engineering discipline strongly suggest to break down programs into manageable, fairly independent modules. MINERVA supports this with seperate namespaces and an intelligent loading scheme. This implements dynamically loadable modules while still allowing fairly strict static checks by the compiler. The overall result is smaller, faster loading and more robust programs.
PrinciplesThe MINERVA compiler minervac produces for each *.min MINERVA source file a *.mpk MINERVA package file with the module interface specification and a *.mbc MINERVA binary code file. A program can access other packages with the package directive. Explicitly referenced predicates which are not defined in the own program and not accessible via package directives are flagged by the compiler with an error. A program exports by default all its predicates. Predicates starting with the underscore character '_' are not exported to the *.mpk file and not accessible by other packages. Predicates with identic name/arity exported by several packages are shadowed by the predicate of the first loaded package. Packages are searched for in the directories and according to the sequence given by the '-sp' parameter of minerva. Even multiply referenced packages will be loaded only once. Name spaces of seperate packages are seperate.
ExamplesThe package "aaa" exports aaa/1, aaa1/1, aaa2/1 but not _aaa3/3. % file: aaa.minThe package "bbb" can access all exported predicates from "aaa" and exports bbb/1 but not _aaa3/3. The definiton of bbb/1 uses _aaa3/3 of "bbb". _aaa3/3 of "aaa" is not accessible to "bbb". % file: bbb.min :- package(aaa)."ccc" can access "bbb" and through "bbb" recursively "aaa". "ccc" exports aaa/1. If "ccc" is loaded first and then the result of ?- ccc(X). is X = 1 because the definition of aaa/1 of "aaa" is accessible to "ccc" but shadowed by the definition of aaa/1 of "ccc". % file: ccc.min :- package(bbb).
Programing RecommendationsWe recommend:
| |||||||||||
| |||||||||||
| Back> |
|