Tcl offers several techniques that can be used to implement static data in command procedures. This page is intended to present the pros and cons.
Example:
Here is a command procedure for a simple Tcl command that makes use of a "static" value. Roughly, it's a constant value that each invocation of the command will use without changing, but a value that need not be created at all if the command is never evaluated.
int OneObjCommand( ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[] ) { Tcl_SetObjResult(interp, Tcl_NewIntObj(1)); return TCL_OK; } Tcl_CreateObjCommand(interp, "one", OneObjCommand, NULL, NULL);