Getting started with CHIP
created November 14, 2003, last update 12 February 2009
In order to use CHIP, it is convenient to create
a directory such as
~user/chip/
where you will store your CHIP programs.
The most
recent CHIP version available at ENSEIRB is CHIP 5.9 available from
since 3 February 2009, on "bang" and "narrhavas" machines only. It is also available from /opt/chip/A_LIRE.ENSEIRB, and older CHIP 5.d versions will remain available from /opt/chip5d/A_LIRE.ENSEIRB, for d = 7, 4, 2.
Then, read file /opt/chip/A_LIRE.ENSEIRB
which tells you that CHIP runs on bang and narrhavas only, and how to run CHIP, e.g.:
- cd
chip
# always start CHIP from the directory of your CHIP
programs;
-
source /opt/chip/A_LIRE.ENSEIRB
-
chip5_xgip
If you are a Unix specialist, you may want to adapt your environment so
as to avoid issuing the "source" command every time. [You may find hints
about that in my obsolete ~gloess/chip/A_LIRE
file that we used with CHIP 5.2 version, which is still available.]
Using CHIP under Emacs
This is the recommended way:
-
Start Emacs from your chip directory;
-
Split your Emacs window into two areas, using Ctrl-x-2 command;
-
Start a shell in one of the buffers, using Meta-x-shell command;
-
start CHIP in that buffer, as explained above;
-
you will run Prolog queries in this buffer;
-
Edit your CHIP program in the other buffer;
-
use the ".pl" suffix for CHIP programs;
-
run the Meta-x-prolog-mode command to make sure your program is recognized
as Prolog, not Pearl!
CHIP programs
CHIP programs are meant to contain programs only (that is, predicate definitions
by means of definite clauses), not queries. If you wish to include test
examples inside your programs, you should therefore comment these test
example queries. Because of a CHIP bug (no CHIP file should end with a
".") you should always include a comment at the end of your file.
Here is a typical example of CHIP file:
~gloess/chip/nat.pl
It illustrates a recommended and convenient file organization.
Note that for better inter-operability with Netscape or other browsers,
you might want to include a .htaccess file such as
~gloess/chip/.htaccess
in your CHIP directory, so that a ".pl" suffix is treated as a ".txt" suffix.
CHIP queries
You type (and run) CHIP queries from the shell where you started CHIP.
A typical CHIP session is shown (within comments) in
~gloess/chip/nat.pl
file: you should copy this file to your directory, and try to reproduce
the CHIP session.
Note that
-
a query consists of one or more atoms, separated by commas, and ending
with a dot;
-
when you type a query, CHIP will print as many answers as there are, one
by one:
-
to look for the next answer, input a ";";
-
to stop looking for other answers, input a ".".
-
the "halt." query will terminate CHIP session.
Each time you have edited (and saved) a CHIP program (say my_program.pl),
and wish to see the effect under CHIP, you should run the
reconsult(my_program.pl).
query. This will replace existing definitions of your program predicates
with the definitions in your file in the CHIP memory. Other
methods are dangerous, because they keep accumulating clauses for the same
predicate!