Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我在 proc 中设置一个局部变量来引用一个全局变量,那么 sub-proc 也可以访问该变量吗?
proc function1 {} { global CAR function2 } proc function2 {} { echo ${CAR} }
不,每个 proc 都必须将变量重新声明为global.
global
您可以使用他的完整限定名$::CAR访问变量,也可以使用uplevel. 否则你需要一个global.
$::CAR
uplevel