The second form of substitution is command substitution. A nested command is delimited by square brackets, [ ]. The Tcl interpreter takes everything between the brackets and evaluates it as a command. It rewrites the outer command by replacing the square brackets and everything between them with the result of the nested command. This is similar to the use of backquotes in other shells, except that it has the additional advantage of supporting arbitrary nesting of commands.
set len [string length foobar] => 6
In Example 1-3, the nested command is:
string length foobar
This command returns the length of the string foobar. The string command is described in detail starting on page 45. The ...