I'm trying to keep my Prolog code modular, and I was wondering if anyone had any advice as to how to do this. The way I was doing this with simple consult
s, but that is getting cumbersome as the number of my files increase and succumbs to name clashes. Is there any construct similar to that of a "typical" import, such as
%-------------------------------------------------------------------- compiler.pl
[ scanner, parser, codegen ] .
%-------------------------------------------------------------------- compile
% compile( S, I ) :- Compiling the source string S gives the list of instructions
% I
compile( S, I ) :- scan( S, T ), parse( T, A ), codegen( A, I ) .
%-------------------------------------------------------------------------------%
at the top of a source file? If it is program specific, I'm using gprolog
. Thanks in advance for any help.
Prolog was one of the first logic programming languages and remains the most popular such language today, with several free and commercial implementations available.
Prolog has been used largely for logic programming, and its applications include natural language understanding and expert systems such as MYCIN. Prolog is notably a so-called nonprocedural, or declarative, language in the sense that the programmer specifies what goals are to be accomplished but not…
Prolog is a logical and a declarative programming language. The name itself, Prolog, is short for PROgramming in LOGic.
Disadvantages of the prolog programmingThe LISP language dominates and overcomes input and output features. The prolog programming does not support graphics features. If you need graphics then you must use turbo prolog. The prolog order affects the efficiency of the programming language.
GNU-Prolog does not have a genuine module system, so your approach is currently the best you can get. Maybe GNU-Prolog might add a module system in the future, but I would not bet a business on it.
The most frequent module system permits to define in different modules predicates with the same predicate name and arity. Thereby name clashes of predicates are avoided. Atoms and functors remain the same over module boundaries. Systems like SICStus, YAP, SWI, Ciao, IF and the ISO standard have such a system.
Another kind of module system is offered by XSB - called functor based.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With