Re: No argv, argc for worker thread



Don, Gerald

I expected that a Tcl interpreter started in any manner would accept options
from its invoker and make them visible to scripts running in the resulting
interpreter.

Why?
* This is how the interpreter works with command line options
* Nearly all Tcl commands accept options of some kind, which are typically
visible in the target
* Using "args" in the proc and itcl method signature supports several Tcl
idioms
* Nothing in the Thread documentation indicates to the contrary
* Passing a list of options from the invoker which are visible to the target
is so common in Tcl, I'm really surprised that this isn't supported when
starting an interp in a thread or as a slave.

So, why not allow options to be passed in and made visible in the global
namespace?

The project at hand launches processes for Tcl app components, passing in
start up command line arguments. I'm refactoring a large component into
several threads. In all components, a "main" script processes command line
options. It then starts scripts or worker threads. The first thing done in
the worker thread is to run this same main script, which establishes the
common run time environment. So, to start a threaded component, I wanted
generate an options list and pass it along with the thread::create command,
just as I'm doing elsewhere. The common main script would process startup
options the same way in a worker thread as it does in the main thread. I
couldn't get that to work and implemented setting argv and argc using
variable passed through the tsv.

The purpose of my query was to confirm that what seemed to be a kluge was
necessary, and thanks for establishing that it its. Deciding whether this
asymmetry is feature or a gotcha is left as an exercise.

Bob


.



Relevant Pages

  • Re: Why doesnt foreach return a value
    ... Every Tcl command is implemented as a C level function. ... What we want at the script level is the ... What changes occur is very specific to the context. ...
    (comp.lang.tcl)
  • Re: Why doesnt foreach return a value
    ... and the completion code of a Tcl command is not a return value. ... value that a Tcl script will see in the interpreter result. ... on the control flow of scripts, but it can be examined directly ...
    (comp.lang.tcl)
  • Re: Design question: C command calling back into Tcl
    ... This command produces lots of data. ... The C code puts the data into a C variable which is linked to a Tcl variable and then calls Tcl_UpdateLinkedVar. ... The respective Tcl variable has a write trace which, when activated, will get the current data item and store it somewhere else. ... - Tcl interpreter calls C command ...
    (comp.lang.tcl)
  • Re: Small embeddable and OSI compliant language?
    ... This may be slightly off topic - I am looking for an embeddable script ... Personally I'd recommend Tcl. ... On-disk footprint on windows is roughly 500k though RAM footprint is ... The interpreter executable is around 20k. ...
    (comp.arch.embedded)
  • Re: A tcl command logger?
    ... >>log each command in the global namespace in a log file. ... tcl 8.4, I finally write a small script to do the task. ... 'expr' to make the evaluation. ...
    (comp.lang.tcl)