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, all data is represented as strings. Strings often take one of three forms. Lists are strings consisting of whitespace-separated values. Using curly braces, list elements can in turn be other lists. Tcl provides several utility commands for manipulating lists. Numeric expressions support variables and essentially the same operators and precedence rules as the C language. Strings often represent commands, the most common use being as arguments to control structure commands such as if and proc.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset