Tcl syntax

Tcl's syntax is small enough to fit in the working memory of a typical human. -- Cameron Laird


The syntax of a Tcl script is minimal and elegant. A basic Tcl interpreter can be extended by adding additional procedures to it. The body of a procedure created using proc is also a script, and is processed as an additional level of evaluation. A procedure might also use one or more of its arguments to create and evaluate a script. Other procedures such as subst perform a subset of the steps performed to fully evaluate a script. Procedures such as exec, expr, glob, and regexp implement their own little languages that are independent of the main interpreter. expr is particularly interesting because it is also features evaluation of arbitrary Tcl scripts, making it a sort of wrapper over standard Tcl.

One of the distinguishing features of Tcl among string-based languages is that although it features substitutions, the substituted values are not themselves scanned for additional substitutions. This gives Tcl a distincly different flavour than Unix shells or TeX.

The syntax of a list is nearly the same as that of a script, except that it omits the dynamic features of substitution and command evaluation. I.e. a command is a list which may contain substitutions in the words.

See Also

Expansion operator: Each item in the following list becomes an additionl word in the current command.
"args" == ARGH! Are they _really_ good for anything? , Brent Welch, comp.lang.tcl, 1994-02-01
BNF for Tcl
A parser's monolog
A basic tutorial explaining how Tcl reads and interprets a command.
An indentation syntax for Tcl
Brace your expr-essions
The various ways of commenting a script.
Rules of Tcl
The "official" rules.
Glossary for Tcl syntax
Hunt for Tcl Extensional Equivalents
Is there a a decent tcl script for finding matching brackets?
Syntax parsing in Tcl
Static syntax analysis
Tcl Quoting
Why is Tcl syntax so weird
In a nutshell: Because it's new to you :)