summaryrefslogtreecommitdiffstats
path: root/doc/SaveInterpState.3
diff options
context:
space:
mode:
Diffstat (limited to 'doc/SaveInterpState.3')
-rw-r--r--doc/SaveInterpState.357
1 files changed, 38 insertions, 19 deletions
diff --git a/doc/SaveInterpState.3 b/doc/SaveInterpState.3
index 96fecdb..619ff0b 100644
--- a/doc/SaveInterpState.3
+++ b/doc/SaveInterpState.3
@@ -1,7 +1,6 @@
'\"
'\" Copyright (c) 1997 Sun Microsystems, Inc.
'\" Contributions from Don Porter, NIST, 2004. (not subject to US copyright)
-'\" Copyright (c) 2018 Nathan Coulter.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -10,8 +9,7 @@
.so man.macros
.BS
.SH NAME
-Tcl_SaveInterpState, Tcl_RestoreInterpState, Tcl_DiscardInterpState \- Save and restore the
-state of an an interpreter.
+Tcl_SaveInterpState, Tcl_RestoreInterpState, Tcl_DiscardInterpState \- save and restore an interpreter's state
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -27,29 +25,50 @@ int
.SH ARGUMENTS
.AS Tcl_InterpState savedPtr
.AP Tcl_Interp *interp in
-The interpreter for the operation.
+Interpreter for which state should be saved.
.AP int status in
-The return code for the state.
+Return code value to save as part of interpreter state.
.AP Tcl_InterpState state in
-A token for saved state.
+Saved state token to be restored or discarded.
.BE
.SH DESCRIPTION
.PP
-These routines save the state of an interpreter before a call to a routine such
-as \fBTcl_Eval\fR, and restore the state afterwards.
+These routines allows a C procedure to take a snapshot of the current
+state of an interpreter so that it can be restored after a call
+to \fBTcl_Eval\fR or some other routine that modifies the interpreter
+state.
.PP
-\fBTcl_SaveInterpState\fR saves the parts of \fIinterp\fR that comprise the
-result of a script, including the resulting value, the return code passed as
-\fIstatus\fR, and any options such as \fB\-errorinfo\fR and \fB\-errorcode\fR.
-It returns a token for the saved state. The interpreter result is not reset
-and no interpreter state is changed.
+\fBTcl_SaveInterpState\fR stores a snapshot of the interpreter state in
+an opaque token returned by \fBTcl_SaveInterpState\fR. That token
+value may then be passed back to one of \fBTcl_RestoreInterpState\fR
+or \fBTcl_DiscardInterpState\fR, depending on whether the interp
+state is to be restored. So long as one of the latter two routines
+is called, Tcl will take care of memory management.
.PP
-\fBTcl_RestoreInterpState\fR restores the state indicated by \fIstate\fR and
-returns the \fIstatus\fR originally passed in the corresponding call to
-\fBTcl_SaveInterpState\fR.
+\fBTcl_SaveInterpState\fR takes a snapshot of those portions of
+interpreter state that make up the full result of script evaluation.
+This include the interpreter result, the return code (passed in
+as the \fIstatus\fR argument, and any return options, including
+\fB\-errorinfo\fR and \fB\-errorcode\fR when an error is in progress.
+This snapshot is returned as an opaque token of type \fBTcl_InterpState\fR.
+The call to \fBTcl_SaveInterpState\fR does not itself change the
+state of the interpreter.
.PP
-If a saved state is not restored, \fBTcl_DiscardInterpState\fR must be called
-to release it. A token used to discard or restore state must not be used
-again.
+\fBTcl_RestoreInterpState\fR accepts a \fBTcl_InterpState\fR token
+previously returned by \fBTcl_SaveInterpState\fR and restores the
+state of the interp to the state held in that snapshot. The return
+value of \fBTcl_RestoreInterpState\fR is the status value originally
+passed to \fBTcl_SaveInterpState\fR when the snapshot token was
+created.
+.PP
+\fBTcl_DiscardInterpState\fR is called to release a \fBTcl_InterpState\fR
+token previously returned by \fBTcl_SaveInterpState\fR when that
+snapshot is not to be restored to an interp.
+.PP
+The \fBTcl_InterpState\fR token returned by \fBTcl_SaveInterpState\fR
+must eventually be passed to either \fBTcl_RestoreInterpState\fR
+or \fBTcl_DiscardInterpState\fR to avoid a memory leak. Once
+the \fBTcl_InterpState\fR token is passed to one of them, the
+token is no longer valid and should not be used anymore.
.SH KEYWORDS
result, state, interp