Version 4 of The Very Minimal Tcl Core Command Set

Updated 2005-12-01 23:02:58

DKF: What is the very minimum set of Tcl commands? Here's an attempt to define them:

string
You have to have some tools to manipulate strings, match them, etc. Could probably leave some parts of this command out. However, strings must use UTF-8 or UNICODE.
expr
You must be able to evaluate expressions.
catch
You must be able to trap errors.
"loop"
While you can use expr to construct if, looping is the only way to get to Turing-completeness (assuming we don't have a very deep stack, as is usually the case!) This could be a simple infinite loop though, with break to terminate it.
return
Speaking of which, we do not need break (or continue or error) if we have this command.
proc
It's not Tcl if you can't create your own commands!
uplevel
This is critical to being able to make your own control constructs, and it is a clear defining feature of how Tcl really works. Also subsumes eval.
rename
All Tcl commands are renameable, and that's vital to how much of the language works internally.
set
Need to be able to set variables.
unset
Need to be able to remove variables.
upvar
This subsumes global and variable, and is also tremendously useful for control constructs again.
"basic IO"
The aim with this is to build enough to support source, though that command is so simple to reimplement in Tcl that it can't be fundamental. However, a minimal command set need not support writing files.
info
Introspection is a key feature of Tcl, but quite a bit of this command (like string, as mentioned above) can be omitted.
unknown
Technically, you don't need to have this. But you do need to have plumbed in support for it; it's the final key defining factor of the language.

Things to go in the second orbit:

interp
This is the heart of our security model.
namespace
There is no other way to do much of this command either.
trace
Another fundamental piece that can be omitted from a minimum minimal system.

Note that there are no list commands; they are reimplementable in terms of string manipulation (though that'll be slow, of course). I've omitted REs too (big, but not fundamental) and dicts (nice to have, but again not required).

[ CL think Donal launched this page while philosophizing for the benefit of the Parroteers. CL finds namespace dispensable, and agrees that REs and dicts are as well. Donal commented, "Note that I'd put encodings and the fuller channel/event model further out. They're vital, but not the heart of the story." I think they are fundamental, in a specific sense, but I'll let them pass for now.]


"Small Tcl"


Category Implementations