A container is an abstract data type for a collection values.
Built-In Containers
- array
- An contains variables. Since an item in array is a separate variable, a trace can be set on it.
- namespace
- A namespace contains variables, routines, and other namespaces. It also has several properties that can be queried and in some cases modified.
Value-based Containers
One of the more unique features of Tcl is that some containiners are implemented as values. Since a value is a string, such containers are also simply strings. Modifying the containiner is done by modifying the string that represents the container. For performance, Tcl tracks whether an actual string is needed, and if not, just performance the logical equivalent of modifying the string.
- dict
- A list where even-numbered items are interpreted as names and odd-numbered items are interpreted as values.
- list
- The standard container for sequences of values.
- deep dict
- A dictionary in which the value of each key is unambiguously either a single value or another deep dict.
- deep list
- A list in which each item is unambiguously either a value or another deep list.
Other Containers Available for Tcl
- dictionary, by Frederic Bonnet
- an implementation of a key-value store, that preceded dict
- vector (BLT)
- one-dimensional arrays of values
- TclX keyed lists
- NAP
- Provides some sort of array/vector data type.