Program Organisation

The chapters so far have covered the basic elements of day-to-day Tcl programming, so-called ‘programming in the small’. In this chapter we now consider how to take a body of Tcl code and package it up so that it can be used and reused by others; ‘programming in the large’. There are a number of issues involved when making some code available for use by other developers, whether you are targetting a small number of colleagues, or making your code available for download by the general public.

In addition, there are other matters which are important to consider when distributing code to other users, such as writing clear documentation, implementing and using a unit and regression test suite, and setting up some means of support, such as a mailing list or forum. These considerations are largely non-Tcl specific, and so are not covered here. Use of the tcltest framework for unit testing is covered in Section 4.4.

4.1  Namespaces

4.1.1  Ensembles

4.1.2  Import and Export

4.1.3  Creative Writing

4.1.4  Paths and Unknown Commands

4.1.5  Abstract Data Types

4.1.5.1  Example: Stacks and Queues

4.1.5.2  Example: Algebraic Types

4.2  Packages

4.2.1  Modules

4.3  Object Oriented Tcl

4.4  Testing

4.4.1  TclTest


1 Malicious tampering is a separate issue, covered in Section 7.4 on safe interpreters.