Re: ANN: Common CLI to quickly check Prolog snippets across many engines

Liste des GroupesRevenir à cl prolog 
Sujet : Re: ANN: Common CLI to quickly check Prolog snippets across many engines
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 10. Nov 2024, 16:22:26
Autres entêtes
Message-ID : <vgqj3j$8iq$1@solani.org>
References : 1
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
Hi,
An alternative minimal approach, which already
works on many Prolog systems is to only require:
<prolog system> <prolog script>
And inside the Prolog text <prolog script>:
:- initialization(my_main)
The initialization/1 directive is from the
ISO core standard. You find some words
about it here:
:- initialization(:Goal)
https://www.swi-prolog.org/pldoc/man?predicate=initialization/1
Bye
P.S.: Next level is option processing, the
minimal being:
<prolog system> <prolog script> <option 1> ... <option n>
But things get very hairy here, for example
SWI-Prolog allows multiple prolog scripts depending
whether it sees an extension .pl on the command line.
And inside the Prolog text you can access the options via:
my_main :-
    current_prolog_flag(argv, L),
    /* your option logic */
Its not in the ISO core standard but also quite common:
argv(list, changeable)
     List is a list of atoms representing the
     application command line arguments.
https://www.swi-prolog.org/pldoc/doc_for?object=current_prolog_flag/2
You can then define options that control your Prolog
program semantically without exposing Prolog code.
The command line DSL of your Prolog program can
be anything need not be Prolog goals. This gives
a more flexible command line interface, since you
can more easily change the implementation,
than when you expose Prolog goals. The command
line DSL can also solve escaping problems different
than the way they can happen with supplying Prolog goals.
Aleks Grabowski schrieb:
Dear All,
 Up until now it was quite time consuming to run your code snippets across
different Prolog engines. Imagine you want to test some corner case of
goal expansion, but you would really like to know how other Prologs
behave, and what is a common practice if any. That's why I wrote a simple
program that will act as a common CLI for different engines. So now you
can just call:
      prologs -g my_goal my_test.pl
 And this will run `my_goal,halt` with all installed Prologs, so in a less
of a second you can see how your code is handled by other engines.
 My first release v.0.1 is available at <https://github.com/hurufu/prolog-
all>, but currently the only supported way of using it is via AUR
repository (https://aur.archlinux.org/packages/prologs) or a Docker
container (https://github.com/hurufu/prolog-docker)
 I hope my program will help at least a little bit with interoperability in
the Prolog community.
 P.S. I know that not a lot of people use Prolog and even less people use
both Prolog and Arch Linux (and read Usenet), but I still hope that this
project will be helpful for somebody else but me ;)
 

Date Sujet#  Auteur
10 Nov 24 * ANN: Common CLI to quickly check Prolog snippets across many engines3Aleks Grabowski
10 Nov 24 `* Re: ANN: Common CLI to quickly check Prolog snippets across many engines2Mild Shock
10 Nov 24  `- Re: ANN: Common CLI to quickly check Prolog snippets across many engines1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal