next up previous index
Next: Command Substitution Up: Interpretation Principles Previous: Interpretation Principles

Variable Substitution

A dollar sign together with an immediately following variable name will be substituted by the value of the variable. $var is thus the same as set var. This is important for dereferencing: if the value of a variable   is the name of another variable, e.g.

% set a b
b
% set b 1
1
we cannot obtain the value of b using the variable substitution on a, using something like $$a. Instead, the set command can be used:
% set $a
1

Note that it does not matter if the dollar sign is preceded by a word separator, so it is possible to create new variable names dynamically:  

% set a abc
abc
% set b$a 1
1
% puts $babc
1


Micha Meier
Tue Jul 2 09:49:39 MET DST 1996