The upvar command is useful in any situation where you have the name of a variable stored in another variable. In Example 7-2 on page 82, the loop variable param holds the names of other variables. Their value is obtained with this construct:
puts stdout "\t$param = [set $param]"
Another way to do this is to use upvar. It eliminates the need to use awkward constructs like [set $param]. If the variable is in the same scope, use zero as the scope number with upvar. The following is equivalent:
upvar 0 $param x puts stdout "\t$param = $x"
Suppose you have a program that maintains state about a set of objects like files, URLs, or people. You can use the name of these objects as the name ...