substitution

The rules of Tcl define three substitutions: script substitution, variable substitution, and backslash substitution.

See Also

double substitution
Commands such as expr, eval, if, for, etc. do their own substitutions, leading to the potential for double substitution.

Description

In substitution a value is interpolated into a word in a command. Because Tcl is a string language, substitution plays a prominent role Even the name of the command can be modified via substitution:

proc p1 {} {
    return {hello from p1}
}

proc p2 {} {
    return {hello from p2}
}

p[incr i] ;# p1 is evaluated
p[incr i] ;# p2 is evaluated