Pie and Shell

BAP Online Manuals : Tools and Examples : Tools : Pie and Shell
Previous: System Status Window
Next: Pulse & Memshow

4.1.2. Pie and Shell

The shell is probably the first BAP program you will meet (in the windows with the 'PROLOG Shell' title). It pops up right after booting the system (Thats because it is the default entry in the 'default file' item of WIO). It appears to be the something like the interactive toplevel of a regular Prolog system. In fact, it's only a loop reading an input line from the text window, parsing the string and calling the result as a Prolog goal. Unbound variables in the string will be returned as results, they are printed into the text window. In case of non-deterministic goals, several results can be returned, for every TRUE solution a semi-colon is printed. A fail will not print anything. Try typing

member (A, [one, two, three])

This will give an impression of how things work.

If the predicate you call is not known to the system the shell will print a warning to the console window. The shell runs a standard Prolog process and can access this processes database. Please enter:

	assert (one)
	assert (two)
	retract (A)

Using libraries and precompiled '.lkd' files requires more effort than using the builtin predicates. Before you can use them, you have to load the code into the network:




(The difference between these two predicates is that load() only loads the code on the current node while load_all() loads the code to all nodes in the network). After this all predicates exported from the new module can be called.

To start Prolog programs that run concurrently to your shell, use the exec predicate. This call will return immediately, with the work being done on another process.

The 'run' predicate combines load and exec, ensuring that the requested code is present on the node targeted by exec.

Try to open up another shell with

	run (shell)

or place it directly on another node:

	set_id(Msg,3,_),exec (Msg,(load(shell),shell))

Here set_id creates a process ID for any process on node number 3, exec places the call on this node on a process that happens to be free.

To leave a shell and close its window simply type exit.

The PIE (Prolog Inference Engine) is a little more complex interactive interface, more similar to traditional Prolog implementations. In addition to the features of the shell, you can use the PIE as a Prolog interpreter by adding clauses to the database or loading files from disk with consult.

	consult ('hanoi.pie')

will load a program solving the well known towers of hanoi problem from the host system into the database. From here it can be executed. Try

	hanoi (4)

If the predicate you call is neither known to the system, nor present in the database, the pie will simply fail. All this is definitely not new to Prolog programmers used to the usual interpreters, in fact the PIE is a little interpreter.

BAP Online Manuals : Tools and Examples : Tools : Pie and Shell
Previous: System Status Window
Next: Pulse & Memshow