Your program is saved to the Pengines Scratchpad server for a period of at least one month. A link to it is given below. Copy the link, send it around, do what you want with it. Anyone in possession of the link will be able to access Pengines Scratchpad with your document loaded and ready to run.
Link:
As a way to learn how to program the interaction between JavaScript and Prolog, and for the purpose of quickly prototyping small Pengines applications, Pengines Scratchpad allows you to write an HTML document in the editor to the left and click the Run button in order to render it in the panel to the right.
Apart from the usual <style>
and <script type="text/javascript">
tags, Pengines Scratchpad also supports a <script type="text/x-prolog">
tag where you can write your Prolog code. You can program against the browser in the same way as you would write your Prolog program in an editor, consult the file, and ask queries in the Prolog REPL. For I/O you must however use pengine_input/2
instead of read/1
and pengine_output/1
instead of write/1
in order to read user's input and write the output from a program.
Note that code supplied by the client cannot be given unrestricted access to Prolog because Prolog gives unrestricted access to the operating system. Therefore, the server examines each goal on safety before execution. For more details, see Help>Help.
As a way to learn how to program the interaction between JavaScript and Prolog, and for the purpose of quickly prototyping small Pengines applications, Pengines Scratchpad allows you to write an HTML document in the editor to the left and click the Run button in order to render it in the panel to the right.
Apart from the usual <style>
and <script type="text/javascript">
tags, Pengines Scratchpad also supports a <script type="text/x-prolog">
tag where you can write your Prolog code. You can program against the browser in the same way as you would write your Prolog program in an editor, consult the file, and ask queries in the Prolog REPL. For I/O you must however use pengine_input/2
instead of read/1
and pengine_output/1
instead of write/1
in order to read user's input and write the output from a program.
Pengines Scratchpad is inspired by web-based tools such as JSFIDDLE in that it allows you to develop a program and then share it with others on the Web. The relevant menu entry is File>Share.
Pengines Scratchpad cannot provide unrestricted access to Prolog because Prolog gives unrestricted access to the operating system of the server. Therefore, the Pengines server examines each goal on safety before execution. This process unfolds the call-tree and verifies all called predicates against a whitelist. It fails on three occasions:
?- pengine_input('>',X), call(X).
Such errors are raised as instantiation errors.
If any of the above happens, the error is printed, along with a chain of intermediate goals that should help finding the culprit. Note that the whitelist is incomplete, i.e., there are many predicates that can be considered safe that are not on the list. Please report such omissions as bugs.
Pengines Scratchpad is implemented in a combination of Prolog, HTML, CSS and JavaScript. The only framework used is Bootstrap and the choice of editor landed on the very capable ACE editor.
Powered by SWI-Prolog and the Pengines package.