Chapter 6

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 ...

Get Tcl/Tk, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.