Scratchpad
  • File
    • New
    • Save
    • Share...
    • Collaborate...
    • Preferences...
    • Print...
  • Edit
    • Undo
    • Redo
    • Indent
    • Outdent
    • Toggle comment
    • Find and replace...
  • Examples
    • Simple
    • Simple chunked answers
    • Output from Prolog
    • Input/Output
    • Queens
    • Web Prolog
    • Client side templating
    • Expert system
    • Non-determinstic RPC
    • Browser with two pengines
    • Escher Scratchpad
  • Help
    • About...
    • Help...

Preferences

General
Editor

Share your program!

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:

About Pengines ScratchpadVersion 0.9.3  

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.

Pengines Scratchpad Help

Table of Contents

  • About
  • Sharing
  • Limitations
  • Technology

About

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.

Sharing

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.

Limitations

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:

  • If insufficient information is available to decide what will be called. E.g., ?- pengine_input('>',X), call(X). Such errors are raised as instantiation errors.
  • If a predicate is found that is not whitelisted. Such errors are raised as permission errors
  • If a called predicate is not defined. Such errors are raised as existence 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.

Technology

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.