On Apr 17, 2006, at 2:46 PM, Andrew Piskorski wrote:
On Mon, Apr 17, 2006 at 10:47:45AM +0100, John Buckman wrote:
Is there any way in AOLSserver 4 to have per-tcl-interpreter global
variables?
You already do. Tcl global variables are per-thread, which is also
per-interpreter.
I don't believe that's true any longer. I read somewhere that this
used to be the case, but at some AOLserver version this was changed
so that globals are cleaned up after each ADP page (I couldn't find
the URL ref for this now).
I wrote some code to test this, something like:
global x
catch {adp_puts $x}
set x 1
it should display nothing on the first run, then display 1 on the 2nd
and subsequent runs. It doesn't -- it always displays nothing.
HOWEVER, Jeremy wrote:
You could throw the handle name into a namespace variable. They
don't currently get cleaned up.
and he's absolutely right, as code like this:
catch {namespace eval space {}}
catch {adp_puts $space:x}
set space:x 1
works as expected. So, Jeremy's tip to put per-interpreter globals
into a namespace is an elegant work-around.
-john
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.