PROLOG Interpreter: A Second Look

Authors

Publication

Pub Details

Date

Pages

See all articles from QL Hacker's Journal 16

Back in QHJ #13 I have a cursory review of the Prolog interpreter written by Hans Lub. I said that when I found the book that the interpreter was based upon, I could look into it further. Well, I found the book; The Art of Prolog by Sterling and Shapiro.

Even though Hans described the book as excellent, I found it a bit heavy. “The Art of Prolog” is your typical college textbook. It is not designed to be an easy introduction to Prolog, but delves a little more in to the theory of logic programming and Prolog. Don’t expect to pick it up and read it lightly.

The documentation for the interpreter is 10 pages long. A separate document detailing all of the keywords or predicates is an additional 5 pages. The documentation is designed only to cover the interpreter and not the language. It does a fine job of covering how to use the interpreter and delves into the nitty-gritty. It covers error messages, limitations, sone do’s and don’ts, using tracing, and any peculiarities of the program.

It comes with a few example programs, which I did not really look at in the first review. These example programs demonstrate the robustness of the interpreter. When the interpreter is described as a learning tool and not a platform for porting Prolog programs to the QL, I figured the interpreter would be only able to handle some simple, short programs.

One example program is an interpreter of a language called Monica. There is even an example Monica program. An interpreter can can write another interpreter is more than just a learning tool.

A couple of example programs are directly from the book, with a few minor changes to fit the interpreter and add a few nice touches.

I compared the list of system predicates for the interpreter and those in the book. The interpreter is missing a few predicates, but seems to have most of the important ones. As mentioned above, any programs taken from the book would have to be slightly adjusted.

The interpreter itself is easy to use. It is designed to handle the QJUMP pointer interface, but can be run with out it. The interpreter does prefer extra memory, but there is a version to run in 128K. Start up is easy and it quickly gives you the “?” prompt.

When I ran the Eliza example program, I thought it was a bit slow, but after I ran it with the Trace function on, I saw how much processing the interpreter was doing. I take back any comments that I might have made about it’s speed. It’s not blazingly fast, but it’s no dog either.

The interpreter does have some QDOS screen predicates so you can “pretty” up your programs. CLS, INK, UNDER, PAPER, CSIZE, WINDOW, and AT are supported. Beware of changing the ink in a program and then running trace. Your trace output will be shown in the new ink color. Red text on black was a bit hard to read.

The interpreter is configurable. You can change the names of the help and start up files. You can add to the start up file and add any of your own “subroutines”, sort of like the way MicroEmacs boots up. You can even change the size of the interpreter screen (something that I previously said could not be done).

The interpreter is sort of shareware and freeware. There is no implied limit on how long you can use the program with out paying the 10 pound fee, but registering will give you the source code and an advanced user manual. The program is dated March 1990 so I don’t know if the author is still supporting it.

Some of the books that I’ve seen on Prolog describe the language as a language of rules and facts. This leads you to believe that Prolog is more for AI work and not general computing. The examples that come with the interpreter and described in the book dispel this belief. One example program is Quick Sort done in Prolog. If Prolog can do Quick Sort, then it can probably be adapted to most computing needs.

I did find Prolog a bit difficult to read. The facts and rules can be easy to read, especially with the simple examples:

male (X) <- father (X, Y).
father (john, mary).

But the code for Quick Sort and some other examples were beyond me. I guess if you can read Lisp, then you will have no problem reading Prolog. If not, find a good book and spend a few hours with it.

Products

 

Downloadable Media

 

Image Gallery

Scroll to Top