subst or eval command is not working in my case ..
% proc sum {a b} {
return [expr $a+$b]
}
%
% set a 1
1
% set b 2
2
% sum $a $b
3
%
% sum {$a} {$b}
can\'t use n
You put the square braces []
to the wrong place (resp. you even don't need them in the eval
case). In the way you wrote the commands the sum {$a} {$b}]
is evaluated before the subst
or eval
command could evaluate the contents of $a
and $b
.
Correct is:
eval sum {$a} {$b}
or
sum [subst {$a}] [subst {$b}]