Version 0 of substitution

Updated 2015-12-06 17:20:12 by pooryorick

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

A substtution is a form of dynamic quoting in which the value of a substitution is interpolated into a word in a command. Because Tcl is a string language, substiution plays a prominent role. Substitution occurs before the the name of the command is read, making it possible to modify even the name of a command with a 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