Tcl does not double evaluate two consecutive dollar signs.
The $thing
characters in your command subst $$thing
are first replaced by the value of $thing
, which is a.b
.
Subsequently, the subst
command is evaluated like this:
subst $a.b
The above subst
command replaces $a
with 1
, which explains why you get 1.b
returned.
A reliable way to do multiple variable interpolation is with the set
command without a second argument. Chain together multiple set
commands to interpolate multiple times.
puts [set thing]
--> a.b
puts [set [set thing]]
--> a
puts [set [set [set thing]]]
--> 1