Search code examples
moduleprologscalabilitymodularitygnu-prolog

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.


Solution

  • Get the current Logtalk development release, which provides full support for the stable release of GNU Prolog 1.4.0. You can get it by doing a Subversion checkout or a Git clone (see http://logtalk.org/download.html for details). Or just mail me privately and I will build an installer for you. Logtalk was designed from the ground up for programming in the large. You can use it to write portable applications (Logtalk runs as-is on nine different Prolog compilers). You can even use it to run Prolog module code in Prolog compilers such as GNU Prolog that don't include a module system. Logtalk comes with more than one hundred examples, portable libraries, portable developer tools, and full documentation. Going from Prolog to Logtalk is quite easy. Writing portable code beats porting every day ;-)