When I first read Bill's article, I somehow missed this particular
criticism. I'm glad Brent called it to my attention, because it is
> Lacks ability to extend Tcl in Tcl. WRONG - as well as obvious things like
> procedures, there are constructs that let you write new control structures,
I'd like to present an example of this. Lindsay Marshall has written
an exception-handling facility for Tcl (called tihsho), modelled on
C++ exceptions, but adapted to Tcl syntax. He provides two
implementations, which function identically. One implementation (the
first to be written, as a morning hack) is in Tcl. The other is a C
extension to the Tcl interpreter.
$ wc -l tihsho.c tihsho.tcl
Not only is the Tcl version shorter, but to me it is much clearer and
easier to understand.
In a (probably futile) attempt to ward off irrelevant rebuttals (as
opposed to relevant ones, which are welcome), I want to make something
I realize that a similar task could almost certainly have been
accomplished in Scheme (for example) with even less code. I am not
attempting to argue that Tcl is special in permitting this; I'm not
But to say that one cannot extend Tcl in Tcl is simply wrong. And
it's interesting to me to note that Tcl permits such feats without
having to resort to things like special forms and macros.