Version 1 of Tcl Command Evaluation: Layer 0: Tcl_ObjCmdProc call

Updated 2004-08-23 18:11:00

The innermost core of any Tcl command is a Tcl_ObjCmdProc, a C routine that matches the prototype:

   typedef int (Tcl_ObjCmdProc) (
      ClientData clientData,
      Tcl_Interp *interp,
      int objc,
      struct Tcl_Obj * CONST * objv);

The caller of the Tcl_ObjCmdProc must pass in the appropriate ClienData value as was previously registered (say, by, Tcl_CreateObjCommand). This indicates that the ClientData value and the Tcl_ObjCmdProc value ought to be stored in the same struct. The Tcl_CmdDeleteProc that will take care of any ClientData cleanup also belongs in that same struct.

The caller will also pass in the interp, objc, and objv values. In the usual case, these values come passed down, originating from the parser. The interp value will have contained within it information about the current namespace, and the current call frame.

Note that the caller of Tcl_ObjCmdProc doesn't have any need to know the command's (preferred) name.

The Tcl_ObjCmdProc can count on the result of the interp having been reset. It is expected to return a return code value. It may set the interp result, if the reset state is not correct. It may also set the errorInfo and/or errorCode values if it is returning TCL_ERROR.

~Current Status

~Possible Enhancements