Jeremy Henty said:
> server, which Dossy has made perfectly clear). When a new thread is
> created,
> is it's Tcl interpreter created from scratch by reexecuting the source, or
> is it simply cloned from a preexisting interpreter? (Or a bit of both?)
Neither, it's executing the init script, created from the source at start
up. I seem to recall a discussion about it here many moons ago and I am
pretty sure that is actually simply created by using Tcl's "info" and
"namespace" commands to see what commands exists in the "master"
interpreter.
Others have suggested here that the newer Tcl versions can do interpreter
cloning and AOLserver should switch to that because it is more efficient
than an init script. Others are sceptical and I have no opinion on the
matter! :)
I do a funky thing in development where I have a filter that sources all
the .tcl files (except init.tcl, where I do all my ns_register_* stuff) on
every request, overwriting the procs defined by the init script. It's not
fast (but not slow enough to notice in dev) but it means I don't have to
restart the server every time I make a change.
> Put it another way, if I stick an ns_log in the source, will I see that
> log message only when the AOLserver process starts, or will it appear
> whenever a new thread is initialised?
Only at startup.
> Do special commands like proc ns_eval,
> ns_register_proc etc. get some special magic to do the right thing?
Only "ns_eval" has the magic powers of it's arguments being executed
whenever a thread is created. (try "ns_eval {ns_log Notice foo}"). The
other ones you mention do nothing more than register things for the server
to handle and do not depend on Tcl per se. What I mean is that somewhere
in the server's C code "/foo" is mapped to the Tcl proc named "foo". When
a request comes in, the server just get's the interpreter for the thread
and tells it to execute the script "foo", which works if that procedure
had been created in your library script.
> If I
> define a proc-like command do I need to bewitch it so that the magic works
> for it too?
I know ACS used something like "ad_proc" that was a special way of
creating a proc, which included documentation. They didn't have to do
anything special to the AOLserver core, giving credibility to me thinking
the init script is created using "info" and "namespace" commands.
You may also like to know that at the end of a request, an interpreter is
cleaned up. This basically means removing all global variables. You should
note that any namespace variables you create DO NOT get cleared out.
Cheers,
Bas.
--
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.