Chapter 2. Tcl Core Commands
This chapter summarizes the features and commands of the core Tcl language, which was developed by John Ousterhout. The chapter is based on Tcl Version 8.0; a few features are not part of Tcl per se, but are included in the Tcl shell and most Tcl applications, so are included here and noted with (tclsh).
Overview
The Tcl interpreter has a simple syntax, making it suitable as an interactive command language and allowing it to be reasonably small and fast.
Tcl programs consist of commands. Commands consist of a command name, optionally followed by arguments separated by whitespace. Commands are separated by newline or semicolon characters. All commands return a value. The user can create new commands (usually called procs), which operate just like built-in commands.
Within commands, the language supports several additional language constructs. Double quotation marks are used to group characters, possibly containing whitespace, into one word. Curly braces group arguments. They can cross lines and be nested, and no further substitutions are performed within them. Square brackets perform command substitution. The text within the brackets is evaluated as a Tcl command and replaced with the result. The dollar sign is used to perform variable substitution and supports both scalar and array variables. C language–style backslash escape codes support special characters, such as newline. The pound sign or hash mark (#) is the null command, acting as a comment.
In Tcl, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access