I’ve created a saved state with a logtalk library of my own and would like to be able to write prolog scripts that can use this library. Something like this :
Using --no-pce avoid including the graphics stuff into the executable. -O removes debug/3 and assertion/1 and optimizes (notably) arithmetic. --undefined=error causes it to fail if the code contains calls to undefined predicates.
For building as part of a Makefile, I have found these options to be useful:
--stand_alone=true
--undefined=error
--on_error=status
--on_warning=status
--foreign=save
--verbose=false % --verbose=true is useful for finding some errors
--no-pce % if not using graphics
I don’t want to compile the script. On the contrary, I want my saved state (mylib_savedstate) acts as a new interpreter, interpreting the script. Because I’ve noticed a saved state runs as an interactive interpreter.
If you save the program using the stand_alone(true) option it is a normal native executable, so you should be able to use it as #! interpreter. The normal saved state on POSIX systems is an sh script.
I’ve tried with stand_alone(true) option. The created file is an ELF executable but it doesn’t change the game :
invoked with !#, the saved state is actually initialized but the script of the user is not taken into account. In place, an interactive interpreter runs.
I’ve tried this too :
swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.4.1)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- qsave_program(dummy, [stand_alone(true)]).
% Disabled autoloading (loaded 45 files)
% Disabled autoloading (loaded 0 files)
true.
?- ^D
% halt
I see. Yes, normal saved states do not process the Prolog commandline arguments, passing all arguments to the application. This means you have two options. Reimplement the commandline processing in the main goal of the saved state or use class(development). From the commandline I used for testing: