Chapter 5 Embedding into Tcl/Tk
This chapter describes how to embed ECLiPSe into a Tcl host program.
Tcl/Tk is a cross-platform toolkit for the development of graphical
The facilities described here make it possible to implement ECLiPSe
applications with platform-independent graphical user interfaces.
The interface is similar in spirit to the ECLiPSe embedding
interfaces for other languages.
An alternative method of using ECLiPSe with Tcl is to use the Tcl remote
interface, described in chapter 6. In this case, the
ECLiPSe is ran as a separate program. The facilities provided by the
remote and embedding interfaces are largely compatible, so that it is
possible to reuse the same Tcl and ECLiPSe code in both interface. The
advantage of the embedding interface is that ECLiPSe is much more
tightly coupled with the Tcl program, and communication between the two is
more efficient. The advantage of the remote interface is that the Tcl and
ECLiPSe programs are not tightly coupled, and in fact can be run on
The tkeclipse development environment is entirely
implemented using the facilities described in this chapter. The toplevel of
tkeclipse is currently implemented using only the embedding interface,
but the development tools can be used with both the embedding and remote
- Strictly speaking, flushing is not
necessary in the embedding case to make the data available to the other
side. However, it is needed in the remote case, and for compatibility and
good practice, flushing is recommended.
- For compatibility with previous
versions of the embedding Tcl interface, the mode can also be
specified as r (equivalent to fromec) or w (equivalent to
toec). These can be somewhat confusing as read/write status depends
on from which side the queue is viewed (a read queue in ECLiPSe is a
write queue in Tcl).
- It is possible to use the same name for both the queue stream itself and
the event. This simplifies the event handler code because it receives that
name as an argument.