> > Jeff, for those of us not especially familiar with the Tcl internals,
> > could you give or point us to a basic explanation of how and why Tcl
> > uses the C stack, as opposed to being "stackless"?  (A Google search

> It's simple in that a call like so:
>
> proc a args { return "foo" }
> proc b args { a }
> proc c args { b }
> c
>
> will cause an "eval stack" push for the calls to 'a' and 'b'.  This means
> you will see something like "Tcl_EvalObj" (or some equivalent) multiple
> times in a C stack trace if you were to have a breakpoint in 'a'.  The

And to finish your question (doh!), the idea of stackless is to jump
right into the start of proc 'b' from eval'ing 'c' (pushing any args
necessary and the like) without going through the Tcl_EvalObj step.
This is done in the TclExecuteByteCode while loop.  It means handling
the stack vars and errors that occur in a very careful manner.  It
makes for a more complex engine, which isn't always better (it isn't
necessarily faster), but reduces stack usage.

BTW, the point of the mod-8-3-4-branch, which has numerous core changes,
is a variation of the core that runs on routers (work paid by Cisco).
The result is actually in use, with some very impressive stats, not to
mention the use case.

Jeff

Reply via email to