21.1.6 Command Substitution

By using square brackets ([]), you can substitute the result of one command as an argument to a subsequent command, as shown in the following example:

set a 12
set b [expr $a*4]

Tcl handles everything between square brackets as a nested Tcl command. Tcl evaluates the nested command and substitutes its result in place of the bracketed text. In the example above, the argument that appears in square brackets in the second set command is equal to 48 (that is, 12* 4 = 48).

Conceptually,

set b [expr $a * 4]

expands to

set b [expr 12 * 4 ]

and then to

set b 48