开发者

TCL: Return to a higher level?

How can I return from a proc to a higher context?

For example: 开发者_Python百科If proc X called another proc Y which called a third proc Z - is there a way to return from Z directly back to X ?


From 8.5 onwards, yes. The return command has a -level option which is used to do just that:

return -level 2 $someValue

Thus, for example:

proc X {} {
    puts "X - in"
    Y
    puts "X - out"
}
proc Y {} {
    puts "Y - in"
    Z
    puts "Y - out"
}
proc Z {} {
    puts "Z - in"
    return -level 2 "some value"
    puts "Z - out"
}
X

produces this output:

X - in
Y - in
Z - in
X - out

Note that doing this reduces the reusability of Z, but that's your business.


if You are call "x process" from "z proc" then loop will create in the your process flow..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜