Version 66 of TclX

Updated 2008-05-15 19:12:11 by torsten

TclX ( ) is an essential package of extensions for Tcl. This package creates interpreters known as tcl. It adds:

  • advanced code loading facility,
  • new programming constructs,
  • debugging and profiling facilities,
  • unix access commands,
  • file I/O facilities including awk-like scanning for strings,
  • extended list and a new key list capability,
  • extended character and string manipulation commands, and
  • time and date manipulation commands.

Extended Tcl is oriented towards system programming tasks and large application development. It provides a variety of additional interfaces to the underlying operating system, as well as many new programming constructs, text manipulation tools, and debugging capabilities.

Over the years, a variety of features originally appeared in TclX, and then, as the ideas were proven, migrated to the Tcl core. These features include Tcl's I/O system, its associative arrays, Internet networking interfaces, upvar, memory debugging... even incr.

TclX includes documentation on debugging memory problems on how to use its keyed list data type, manipulating binary structures via handles, a guide to writing Tcl commands in C , and a reference manual for the new TclX commands themselves.

(Give an alternate description of TclX as Tcl augmented with POSIX stuff, such as fork, plus other conveniences common among Unixoids, including keyed lists, profiling, signal and kill, ...)

On SourceForge it can be found at

see for a tar file of the cvs head .

The ActiveTcl Batteries Included distribution includes TclX.

TclX Future contains discussion about the interface and interaction between Tcl and TclX.

TclX Commands has a list of TclX's commands

TclX Evolution, State and History:

Karl Lehenbauer first wrote TclX, and he and Mark Diekhans maintained it for a long time. In spring 2002, Jeffrey Hobbs is "reforming" TclX, although he doesn't "own" it.

JH: TclX 8.4.0 was released on Nov 21, 2005. There is no more Tk (aka wishx) component or stand-alone binary ('tcl' exe) support. It is a true extension, now with better portability and a cleaner codebase.

Replacement for wishx

Put this script, called wishx and marked executable, in your path:

 exec wish "$0" ${1+"[email protected]"}
 package require Tk
 package require Tclx
 set argv [lassign $argv argv0]
 source $argv0

Note: script fixed by MS after a bug report in clt [L1 ]

How many people use TclX for Unix System Programming?

See also scanxxx without tclx

DKF: TclX is useful when you're running tclsh in setuid or setgid mode, since it's id command can be used to perform the uid/gid changing often required when doing such things.

TR - The manual 'ObjCmdWrite.3' (TclCommandWriting - Writing C language extensions to Tcl) is a nice introduction to writing Tcl commands in C. In the 8.4 version there is an example for the reversion of a list, which is not only incomplete but also wrong. I liked the example as such, so here comes a correct version (not targeted at TclX but Tcl in general):

 lreverseCmd(ClientData notUsed, Tcl_Interp *interp, int objc,Tcl_Obj *const objv[])
    int listObjc, listIndex;
    Tcl_Obj **listObjv;
    char *temp, *resultList;
    Tcl_Obj *newListObjv;

    /* Verify argument count.  Since we take only one argument, argument
  • count must be 2 (command plus one argument).
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "list");
        return TCL_ERROR;
    /* Create an object to handle the new list we're creating */
    newListObjv = Tcl_NewObj();

    /* Crack the list at objv[1] into its own count and array of object
  • pointers.
    if (Tcl_ListObjGetElements(interp, objv[1], &listObjc, &listObjv) !=  TCL_OK) {
        return TCL_ERROR;

    /* For each element in the source list from last to first, append an
  • element to the new list.
    for (listIndex = listObjc - 1; listIndex >= 0; listIndex--) {
        Tcl_ListObjAppendElement (interp, newListObjv, listObjv[listIndex]);
     return TCL_OK;