Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tcl_Preserve() and Tcl_Release() for new interpreters

50 views
Skip to first unread message

Erik Leunissen

unread,
Sep 7, 2007, 2:59:18 AM9/7/07
to
I'm making use of an interpreter created by:

newInterp = Tcl_CreateInterp();

In the Tcl sources, I found that evaluation of scripts in an interpreter
occurs inside is a surrounding pair of Tcl_Preserve(newInterp) and
Tcl_Release(newInterp). The reason for this may be given by the manual
page for Tcl_CreateInterp(), which says:

"...
Tcl implements a simple mechanism that allows callers to use
interpreters without worrying about the interpreter being deleted in a
nested call.
..."

My question is:
"Does a pair of Tcl_Preserve(newInterp) and
Tcl_Release(newInterp) protect against anything else besides nested
attempts to interp deletion?

The reason I ask is that, in my case, I believe to have complete control
over the code executed by the new interpreter. I also believe to know
that there is no code that deletes the interpreter. If that is true,
then I might safely omit the Tcl_Preserve/Tcl_Release pair.

However, if the Tcl_Preserve/Tcl_Release pair protects against other
things as well, then I may be wrong to omit them.

Thanks in advance for any insight,

Erik Leunissen
--
leunissen@ nl | Merge the left part of these two lines into one,
e. hccnet. | respecting a character's position in a line.

Joe English

unread,
Sep 14, 2007, 1:10:36 PM9/14/07
to
Erik Leunissen wrote:
>I'm making use of an interpreter created by:
>
> newInterp = Tcl_CreateInterp();
>
>In the Tcl sources, I found that evaluation of scripts in an interpreter
>occurs inside is a surrounding pair of Tcl_Preserve(newInterp) and
>Tcl_Release(newInterp). The reason for this may be given by the manual
>page for Tcl_CreateInterp(), which says:
>
>"...
>Tcl implements a simple mechanism that allows callers to use
>interpreters without worrying about the interpreter being deleted in a
>nested call.
>..."
>
>My question is:
>"Does a pair of Tcl_Preserve(newInterp) and
>Tcl_Release(newInterp) protect against anything else besides nested
>attempts to interp deletion?
>
>The reason I ask is that, in my case, I believe to have complete control
>over the code executed by the new interpreter. I also believe to know
>that there is no code that deletes the interpreter. If that is true,
>then I might safely omit the Tcl_Preserve/Tcl_Release pair.
>
>However, if the Tcl_Preserve/Tcl_Release pair protects against other
>things as well, then I may be wrong to omit them.

If you really do have complete control over the code executed
by the new interpreter, then no: Tcl_Preserve()/Tcl_Release()
isn't necessary.

--JE

Erik Leunissen

unread,
Sep 24, 2007, 6:55:20 AM9/24/07
to
Joe English wrote:
>
> If you really do have complete control over the code executed
> by the new interpreter, then no: Tcl_Preserve()/Tcl_Release()
> isn't necessary.
>

Thanks for the clarity Joe.

B.t.w: something amiss with my news group access. I only saw your answer
today 24-Sep-2007. When checking this "thread" (at most) three days ago,
I didn't see your post, although it is dated at 14_sep-2007.

So much for communication latency.

Erik

0 new messages