The following still works, although the new C-ification technique (see directories pl2c, dynpl2c) can now create true one-file standalones.
It is possible to create (as in the past) a small runtime application (called "newappl.bp"), from file.pl as follows:
?-make_appl('<file>.pl').
Deliver the appropriate "bp" file (the Prolog engine) with your application. The user must type:
$ bp newappl.bp
to start it.
Note: the file must contain a clause
main(X):-...
That's where execution starts. BinProlog's shell is nothing but such an application which starts with a toplevel loop i.e. something like:
main(X):-toplevel(X).
As a new feature, you can override this behavior, even for the standard BinProlog system containing the predicate main/1 (which starts the interactive top-level), by defining a predicate main/0 in your program file. In this case, main/0 becomes the new starting point.
You can also generate (on UNIX systems) stand-alone executables that dynamically start the emulator (thanks to Peter Reintjes for suggesting this). You can do something like:
% FILE: hello.pl main(true):-write(hello),nl. % DO: % ?-make_executable_unix_appl( % '/usr/local/bin/bp -q5', % AbsolutePathToEmulator (q=quietness) % 'hello.pl', % SourceFile % hello). % ExecutableFile
In the case of the "hello.pl" program, the user must type, at the Unix prompt:
$ hello
to start it.
The code of this primitive is at the end of the file co.pl.
Again, we recommend using the C-ification technique which can already speed up most applications and in the future will generate very fast code competitive with native code compilers.
You can bootstrap the compiler, after modifying the *.pl files by:
?- boot. ?- make.
or, similarly for any other project having a top *.pro file:
?-make(ProjectFile). ?-make(ProjectFile,Module).
or
?-cmake(ProjectFile). ?-cmake(ProjectFile,Module).
if you intend to generate C-code and possibly hide non-public predicates inside a module.
This allows to integrate your preferences and extensions written in Prolog to the BinProlog kernel.
Make sure you keep a copy the original wam.bp in a safe place, in case things go wrong when you type
?-boot.