Version 1 of Calling Maxima from Tcl

Updated 2004-07-22 15:08:34 by TV

TV

I've thus far tested Maxima on windows (XP), and it proved to be usefull and useable, not in the least because of it's integration with tcl, though maybe that isn't perfect from a strict programmer's point of view.

The mechanism which is used in maxima to interface between the Tcl and Tk supplied user interface (at least on windows) is that a maxima process communicates with the Tcl/Tk interface process over a socket, over which mainly text is being send back and forth containing mathematica statements/commands/formulas and the answers from the maxima 'engine', a technique succesfully used in professional software of various kinds. The possible disadvantage is that for each communication, process change is needed in the process time slicer, which probably works at at most a granularity of a millisecond or so. Most maxima commands aren't executed blazing fast, and usually don't really need to, so that in practice is probably not a granularity problem.

As stated on the maxima page, the way normally the tcl/tk + maxima 'program' maxima.exe communicates the user input to the maxima lisp based core primarily by reading from and outputting to a text widget, which from UI perspective is not a bad idea. In fact it appears the maxima.exe is a tclkit (tcl+tk+incrtcl+metakit) appearently calling some scripts, and in the same dir with as.exe, gcc.exe, and some dlls. Not very handy in my opinion, I'd prefer a few script files which simply normally start up tcl/tk of which I control the installation, which works fine for me, and would seem to require less files, and be more overseeable. Maybe I'll try, and in the process see if that way a more recent tcl/tk can be used.

The maxima tcl procedure to make user interactions work is that somehow pressing return in the .maxima.text widget invokes the routine CMeval with (normally) the window name .maxima.text as only argument. This procedure does some regexpr stuff and basically pushes the maxima input line where the cursor is through the maxima command socket stream to the engine.

The socket of this non-blocking connection has a fileevent readable routine scheduled to activate when data arrives back from the engine: maximaFilter .maxima.text sock156 (second argument depending on session of course).