The return value from Tcl_EvalObj is one of the Tcl return codes TCL_OK, TCL_ERROR, TCL_RETURN, TCL_BREAK, or TCL_CONTINUE, and a result object containing additional information (a result value or error message) that can be retrieved using Tcl_GetObjResult. If an error occurs during compilation, this return information describes the error. Otherwise, this return information corresponds to the last command executed from objPtr.
Tcl_GlobalEvalObj is similar to Tcl_EvalObj except that it processes the command at global level. This means that the variable context for the command consists of global variables only (it ignores any Tcl procedure that is active). This produces an effect similar to the Tcl command ``uplevel 0''.
During the processing of a Tcl command it is legal to make nested calls to evaluate other commands (this is how procedures and some control structures are implemented). If a code other than TCL_OK is returned from a nested Tcl_EvalObj invocation, then the caller should normally return immediately, passing that same return code back to its caller, and so on until the top-level application is reached. A few commands, like for, will check for certain return codes, like TCL_BREAK and TCL_CONTINUE, and process them specially without returning.
Tcl_EvalObj keeps track of how many nested Tcl_EvalObj invocations are in progress for interp. If a code of TCL_RETURN, TCL_BREAK, or TCL_CONTINUE is about to be returned from the topmost Tcl_EvalObj invocation for interp, it converts the return code to TCL_ERROR and sets the interpreter's result object to point to an error message indicating that the return, break, or continue command was invoked in an inappropriate place. This means that top-level applications should never see a return code from Tcl_EvalObj other then TCL_OK or TCL_ERROR.
Copyright © 1996-1997 Sun Microsystems, Inc. Copyright © 1995-1997 Roger E. Critchlow Jr.