0
我有以下伪程序里面,可变范围的程序
proc main2 {} {
set mainVar 100
proc subproc1 {} {
puts $mainVar
}
subproc1
}
main2
它引发错误无法读取“mainVar”:没有这样的变量。我的问题是,如果我在proc中声明一个变量(即mainVar)不是应该可以在该proc中的任何位置访问该变量吗?为什么它不能在mainproc proc中声明的另一个proc中访问?请在这里写一些东西