Subject: Re: [SWIPL] libraries written in Prolog

From: Jan Wielemaker <[email-masked]>
Date: Fri, 25 May 2001 11:37:19 +0200

Bill,

> I am writing a speech synthesizer in Prolog. I am 
> writing it to be very extendable. I would like to have parts
> of it compiled as libraries that can be used to build other 
> applications (much like an SDK). Is this something that
> can be done in Prolog?

Talking SWI-Prolog, as the details will vary from system to system.
Normally I would simply stick all the stuff in a directory, make sure
all files are module files (but really, once you start thinking of
code that should be used more than just once you should use modules).
Now run ?- make_library_index(mydir). to create an INDEX.pl.

Now all you have to do is add this directory to the library search
path by adding a rule to user:file_search_path/2.

At least for SWI-Prolog there is little reason to compile it, unless
it is *really* big.  In that case you can use qcompile/1 to compile
(part of) the library to .qlf files.  .qlf files require about 10
times less CPU time to load, but in practice the time for locating,
opening and reading the file outweights on typical source-files.
The .qlf format is highly version dependant as it is just a dump
of the virtual-machine instructions.

You can have a look at how the XPCE library is added to the system.

	Cheers --- Jan

P.s.	In a wider context I'm a bit worried on these issues.  Using
	file_search_path/2 is a great way to organise the file-structure,
	but the module name-space and public predicate namespaces are
	flat.

	If we just keep adding modules to the library, eventually it
	will become unmanagable.  I'm seeking for solutions that
	preferably fit with some kind of standard.