Re: SWI-prolog, runtime, how-to

From: Jan Wielemaker (jan_at_ct.xs4all.nl)
Date: 04/13/04


Date: 13 Apr 2004 19:15:49 GMT

In article <b2180865.0404130833.39392a4c@posting.google.com>, Will Briggs wrote:
> Sorry, I tried a different search term after posting my query (which I
> can't make this a reply to on Google groups). Here was the answer:
>
> main :-
>|> unix(argv(Argv)), % still Quintus compatibility

You can also use current_prolog_flag(argv, Argv), which is the basic
mechanism to get the argument vector. There are a few other Prolog
systems using this API.

This, like qsave_program/2, generates a saved-state. On Linux the default
is to use a little /bin/sh script. Using the option --stand_alone=true
(or stand_alone(true) for qsave_program/2) the emulator itself is added
in front of the saved-state, resulting in a single-file executable that
requires no other files at runtime (unless you explictely try to load
Prolog resources during the execution of your program of course).

For small things on systems where it is no problem to have Prolog
installed, use scripts using the #! notation. Smaller and easier!

        --- Jan

>|> append(_, [--|AppArgs], Argv), !,
>|> parse(AppArgs),
>|> halt.
>|>
>|> parse(Argv) :-
>|> format('Called with argv ~w~n', [Argv]).
>
>|> % pl -o test -f none -g main -c load.pl
>|> load.pl compiled, 0.00 sec, 1,312 bytes.
>|> /staff/jan/lib/pl-3.2.8/library/quintus compiled into quintus,
>|> 0.00 sec, 9,792 bytes.
>|> % ./test hello world
>|> Called with argv [hello, world]
>|> %
>
> from http://groups.google.com/groups?q=swi-prolog+executable&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=7kv9jp%245rr%40news-rocq.inria.fr&rnum=1



Relevant Pages

  • Re: Prolog query arrangement on efficiency
    ... Here is a portion from the paper of inefficiency reason that I had ... also experienced today because of the query arrangement. ... The effect of a Prolog implementation technique called indexing. ... descendants, each of which has 1000 descendants, giving 10000 leaves. ...
    (comp.lang.prolog)
  • Re: Prolog doesnt give multiple solutions to my goal.
    ... | "ground toplevel queries have only one answer" ... Not Prolog According to the Gospel of ISO, but it will be some day. ... I would suggest you keep in mind one elementary fact about the Prolog Inference Engine, that is, absent various non-logical features of Prolog that prevent it from doing so completely, the PIE finds constructively all combinations of ground terms that exist in the given rules and can logically be assigned to the free variables in the query that *refute* the assertion ...
    (comp.lang.prolog)
  • Re: communicate with Prolog engine in Prolog
    ... Even when the predicate does not terminate it may be useful to use ... something like a metainterpreter. ... Suppose users may query a Prolog program through a web interface. ...
    (comp.lang.prolog)
  • PySWIP 0.1.2 released
    ... PySWIP is a GPL'd Python/SWI-Prolog bridge enabling to query SWI- ... Prolog in your Python programs. ...
    (comp.lang.python.announce)
  • Re: GNU prolog is not so reliable as SWI-prolog
    ... nothing about programming languages. ... Please refrain from posting here ... But the SWI prolog just can do well without needing manipulation. ...
    (comp.lang.prolog)