summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-06-11 09:06:57 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-06-11 09:06:57 (GMT)
commit1a932ea88a9fde0251fb86c3473eb6766d1e3f0c (patch)
treeb48ae3e90f09ae7a5aa73521d28d4b1e2bad78aa /doc
parent4761143bfb57d06fc14fd535a1682b3fe76b26a7 (diff)
parentef2e5e5a2e8bd5a470265099d9ccb7d096692c59 (diff)
downloadtcl-1a932ea88a9fde0251fb86c3473eb6766d1e3f0c.zip
tcl-1a932ea88a9fde0251fb86c3473eb6766d1e3f0c.tar.gz
tcl-1a932ea88a9fde0251fb86c3473eb6766d1e3f0c.tar.bz2
Backout [0ef72df401df2216]: "Tighten up SaveResult.3". Will be put in a separate review for 9.0
Diffstat (limited to 'doc')
-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..ce7f74a 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. There are two triplets of routines meant to work together.
.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.
+The first triplet stores the snapshot of 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