Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programming in the large with prolog

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 consults, 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.

like image 213
Sean Kelleher Avatar asked Jul 14 '11 15:07

Sean Kelleher


People also ask

Is Prolog used commercially?

Prolog was one of the first logic programming languages and remains the most popular such language today, with several free and commercial implementations available.

What is Prolog programming language used for?

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…

Is Prolog a programming language?

Prolog is a logical and a declarative programming language. The name itself, Prolog, is short for PROgramming in LOGic.

What are the disadvantages of Prolog?

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.


1 Answers

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.

like image 50
false Avatar answered Nov 21 '22 15:11

false