%
% sccsid("@(#)README	1.4          93/12/16").
% sccscr("@(#)  Copyright 1993 ECRC GmbH ").
%

This is ProTcl (pronounced pro-tickle), the Prolog interface to Tcl/Tk,
version 1.1. It is a rather lightweight interface, it allows to evaluate
Tcl expressions in Prolog and has also a rudimentary possibility
of callbacks from Tcl to Prolog.

This version corresponds to Tcl7.3/Tk3.6. The distribution
of these Tcl/Tk versions is included so that the package is
self-contained.

To find out more about Tcl/Tk, read the README files in the Tcl/Tk
distribution.

The interface has been tested with ECLiPSe 3.4 and SICStus 2.1 on
a Sparc 10. I expect it to work with Quintus, however interactive
use and callbacks must be implemented by someone else as I don't
have Quintus 3.x. If you change the code to run on other machines,
please send me the diffs so that I can update the source.

The software is delivered as is, without any explicit or implied warranty.
Questions regarding Tcl/Tk itself can be sent to the Usenet group
comp.lang.tcl, questions regarding Prolog to comp.lang.prolog,
ECLiPSe questions to eclipse_users@ecrc.de and SICStus questions
to sicstus-users@sics.se.

Bugs and suggestions please to micha@ecrc.de.

Installation
------------

1) Install Tcl and Tk.
2) Modify the makefile macros that denote important directories.
3) make <prolog system>, one of {eclipse, sicstus, quintus}
4) The interface is loaded into prolog by :- use_module(library(tk)).
   The makefile itself does not create a saved state, it only sets up
   the necessary files. You can make a saved state after loading ProTcl.


Bugs and problems
-----------------

I see a potential problem with SICStus and other Prologs that
do not have explicit volatile strings - when atoms are used
to send commands to Tcl, the Prolog atom table can be soon
filled up. To avoid this, ProTcl should be extended to provide
direct interface to the Tk functions so that the Tcl interpreter
does not have to be invoked. This, one one hand, would make the interface
tighter and better (one can use Prolog variables directly), on the
other hand it would become more dependent of the Tk source.
I guess we shall wait and see.

To port the whole functionality of ProTcl to another Prolog, two
nontrivial tasks must be accomplished:
1) To use Tk interactively, it is necessary that the Prolog system
   checks for X events frequently enough. In practice, this means
   that while waiting in the top-level loop for the next query,
   the Prolog process cannot block, but it has to process X events.
   Many Prolog systems have hooks in the top-level loop or in the
   read predicate itself, which allow to call a user-defined predicate
   before issuing a blocking read. This predicate should call
   Tk's function DoOneEvent and after return it should check if
   there is data on the input stream and if so, read the query,
   otherwise wait for the next event. This is possible because
   data on input will also cause an X event.

2) One way to call Prolog callbacks is to
   call Prolog from C. In this case a function call_prolog()
   should be written, which will be called when the Tcl command
   'prolog' is executed.

3) Another and better possibility is to use the prolog_event
   command which stores its arguments and returns, and these
   arguments can be retrieved in Prolog and used to call
   a Prolog callback predicate.
