From: Thomas MENEZ on
Is there a way to retrieve all the current existing code and variables
from an existing interpreter ? One of Tcl's strength is its
introspection capability. But how can I achieve this ?

Thanks.

From: Larry W. Virden on
On May 6, 11:47 am, Thomas MENEZ <menez.tho...(a)gmail.com> wrote:
> Is there a way to retrieve all the current existing code and variables
> from an existing interpreter ? One of Tcl's strength is its
> introspection capability. But how can I achieve this ?

Have you read the reference material about Tcl's info command? While
not all of Tcl is available for instrospection, the info command
provides the interface to all parts that are.

An example of something that isn't introspectable would be C code for
a Tcl function. If you try to get the code for a C function, info
body will respond that "tell" isn't a procedure (or whatever other
function you tried).

From: Uwe Klein on
Thomas MENEZ wrote:
> Is there a way to retrieve all the current existing code and variables
> from an existing interpreter ? One of Tcl's strength is its
> introspection capability. But how can I achieve this ?
>
> Thanks.
>
Serializing interps:
http://wiki.tcl.tk/_//search?S=serializ

uwe
From: Larry W. Virden on
On May 6, 11:47 am, Thomas MENEZ <menez.tho...(a)gmail.com> wrote:
> Is there a way to retrieve all the current existing code and variables
> from an existing interpreter ?

Note that there is an issue that has to be considered when retrieving
variables. Some variables have embedded state that is not
traditionally accesible.

For example:

set fd [open "/tmp/status" "r"]
set buff [gets fd]
set buff [gets fd]

# If, at this point, you captured the code and variables, you
# would find that $fd has a value similar to "file4".
# however, that does not provide you any indication of what data would
be read
# by the next gets call, etc.
From: tom.rmadilo on
On May 6, 9:57 am, "Larry W. Virden" <lvir...(a)gmail.com> wrote:
> On May 6, 11:47 am, Thomas MENEZ <menez.tho...(a)gmail.com> wrote:
>
> > Is there a way to retrieve all the current existing code and variables
> > from an existing interpreter ?
>
> Note that there is an issue that has to be considered when retrieving
> variables. Some variables have embedded state that is not
> traditionally accesible.
>
> For example:
>
> set fd [open "/tmp/status" "r"]
> set buff [gets fd]
> set buff [gets fd]
>
> # If, at this point, you captured the code and variables, you
> # would find that $fd has a value similar to "file4".
> # however, that does not provide you any indication of what data would
> be read
> # by the next gets call, etc.

Something left out of this discussion is the "point-in-time" at which
an interp state is captured.

I would suggest looking at AOLserver's init/reinit script:

http://junom.com/gitweb/gitweb.perl?p=aolserver.git;a=blob_plain;f=nsd/init.tcl;hb=origin

You can't directly use this script, but the issue is more complicated
than what is covered in the wiki.