next up previous contents
Next: Avoiding Various Kinds Up: Interactive Program Development Previous: A Problem with

Two Variations on Program Development

The first variation depends on whether or not you are using a unix shell that allows for job suspension. This can be checked by getting into Prolog and issuing the character ^Z which is the usual default for suspending a job. You then find yourself at the unix level where you can edit your file in the normal way. When you have finished editing, get back into Prolog with the command:

 
unix prompt:  fg

which stands for bringing a suspended job into the foreground. Now you are back in Prolog and you have to reload your program using consult/1gif.

The second, more satisfactory variation depends on defining a predicate which can be used to edit a file without explicitly leaving Prolog. This can be done because there is a built-in predicate shell/1 which takes as its argument a unix command as a list of the ASCII codes associated with the characters forming the command. Here is a simple program that, if loaded, can be used to edit a file and automatically reconsult it after the edit is finished.

Now you have to remember to load this each time you enter Prolog. One way this can be done is by having a file called prolog.ini in your home directory. This file will then be automatically consulted each time you enter Prolog. Put the above program in such a file and try it out. Note also that you can change the editor of your choice by redefining editor/1. The predicate append/3 is very useful: it `glues' two lists together --- e.g. the goal append([a,b],[c,d],X) results in X=[a,b,c,d]. It is so useful that you will probably want it around all the time.



next up previous contents
Next: Avoiding Various Kinds Up: Interactive Program Development Previous: A Problem with



Paul Brna
Mon May 24 20:14:48 BST 1999