Complex Data Structures with Lists, Arrays and Dicts
This chapter demonstrates how lists, arrays and dicts can be used to group data into constructs similar to C structs, linked lists, and trees. Tcl has been accused of being unsuited for serious programming tasks because of the simplicity of its data types. Whereas Java has integers, floats, pointers, structs, and classes, Tcl had only strings, lists and associative arrays. The 8.5 release added the dict data structure to Tcl, and 8.6 adds classes and more. The simple constructs are frequently sufficient. This chapter will show some techniques for using Tcl data constructs in place of the more traditional structs, linked lists, and so on.
The first examples show how lists can be used ...