Here is the code I am testing:
proc check_eval {} {
set cmd {set return_val {}; set return_val}
puts "Command to evaluate : $cmd"
uplevel eval $cmd
}
I encountered the following problem: when I am calling "check_eval", it looks like the statement "set return_val {}" is ignored. I.e., the interpeter looks for existing return_val variable in the calling scope. Example:
tcl>unset return_val
tcl>check_eval
Command to evaluate : set return_val {}; set return_val
can't read "return_val": no such variable
while evaluating check_eval
tcl>set return_val 556
556
tcl>check_eval
Command to evaluate : set return_val {}; set return_val
556
tcl>
On the other hand, if I replace "set return_val {}" in the procedure by, for example, "set return_val 10000", it will show 10000 when running:
tcl>set return_val 556
556
tcl>check_eval
Command to evaluate : set return_val 10000; set return_val
10000
tcl>set return_val
10000
Does anybody can explain me please what is going on here?
Thanks.