Node:Putting it all together, Next:Quick Reference, Previous:The Prolog library, Up:Tcl/Tk library
At this point we now know Tcl, the Tk extensions, and how they can be
integrated into SICStus Prolog through the tcltk
library 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:
tcl_eval
prolog
tcl_event
tk_next_event
prolog_event
With these interaction primitives there are three basic ways in which Prolog and Tcl/Tk can be organized:
prolog
function.
tcl_eval
function
tcl_event
,
tk_next_event
, and prolog_event
.
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.