Chapter 7

Procedure Techniques

One key to writing modular code is dividing large programs into smaller subroutines. Tcl supports the common programming concept of subroutines—procedures that accept a given number of arguments and return one or more values. Tcl also supports procedures with variable numbers of arguments, and procedures with arguments that have default values.

The Tcl interpreter allows scripts to rename procedures and create new procedures while the script is running. When a new procedure is created by another procedure, the new procedure is defined in the global scope and is not deleted when the procedure that created it returns.

Previous chapters introduced some of these capabilities. This chapter expands on that discussion ...

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.