At this point we now know Tcl, the Tk extensions, and how they can be
integrated into SICStus Prolog through the
module. The next problem is how to get all this to work together
to produce a coherent application. Because Tcl can make Prolog calls and
Prolog can make Tcl calls it is easy to create programming spaghetti.
In this section we will discuss some general principles of organizing
the Prolog and Tcl code to make writing applications easier.
The first thing to do is to review the tools that we have. We have two programming systems: Prolog and Tcl/Tk. They can interact in the following ways:
With these interaction primitives there are three basic ways in which Prolog and Tcl/Tk can be organized:
These are three ways of organizing cooperation between Tcl/Tk and Prolog to produce an application. In practice an application my use only one of these methods throughout, or may use a combination of them where appropriate. We describe them here so that the developer can see the different patterns of organization and can pick those relevant to their application.
|• Tcl The Master:||Tcl The Master, Prolog The Slave|
|• Prolog The Master:||Prolog The Master, Tk The Slave|
|• Prolog And Tcl Interact through Prolog Event Queue:||Prolog And Tcl Interact through Prolog Event Queue|
|• The Whole 8-Queens Example:||The Whole 8-Queens Example|