Skip to content
Tcl Source Code View Ticket
Login

View Ticket

How to save/restore Tcl interpretor state in C ?

Closed / Fixed218408ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:57:13
OriginalBugID: 5369 Bug
Version: 8.3.1
SubmitDate: '2000-05-05'
LastModified: '2000-05-11'
Severity: LOW
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
OS: Windows NT
FixedDate: '2000-10-25'
ClosedDate: '2000-05-11'


Name:
Christophe Cognault

ReproducibleScript:
In C code, I want to save interpretor state, do a Tcl_Eval and
restore interpretor state, but I don't find any API
suitable for my need.

In details:

I need that because I translate error message in C code by using
Tcl_Eval of an 'msgcat::mc' command, but I don't want that
this particular Tcl_Eval modify the current interpretor state.
Use of Tcl_SaveResult/Tcl_RestoreResult and saving/restoring
errorInfo and errorCode are not sufficient because Tcl_Eval
modify the flags of current interpretor and I cannot save/restore
these flags. And so, in case of error, after translation done,
I loose call stack up to C code, e.g.:
I have Tcl code that calls a command implemented in C that calls
Tcl code with Tcl_Eval. In case of error in the inner Tcl code,
I want to get all the call stack in errorInfo, BUT my C code
calls Tcl_Eval another time in order to translate an error message
and the second Tcl_Eval erases Interp::flags of current interpretor
so I loose the call stack in errorInfo, 
because, on next call to Tcl_AddErrorInfo, errorInfo is cleaned.

I think to use 2 interpretor, a main interpretor and a "translator"
interpretor but this is not very convenient for my application,
so at this moment I implement a kind of Tcl_SaveState/Tcl_RestoreState
(but in a very bad way, no stubs, save very few things, bad code...)
and I see in tclNamesp.c (1.17) at line 371 in func Tcl_PopCallFrame
a comment saying:
     * What's really needed is a general-purpose mechanism for saving and
     * restoring interpreter state.

So is this mechanism planned or event exist ?

DesiredBehavior:
Having Tcl_SaveState/Tcl_RestoreState in C API ?



The user is likely better off with the two interp model, because
there is nothing in the Tcl C API to exactly handle what they need,
aside from the Tcl*Result functions. 
-- 05/11/2000 hobbs
welch Closed ticket [218408ffff]. [History diff]2000-10-26 08:21:18
dgp Open ticket [218408ffff]. [History diff]2001-04-20 02:19:52
dgp Closed ticket [218408ffff]. [History diff]2001-04-20 02:20:47
Log in (anonymous is fine) to add a comment.