Tcl中不能自定义的if命令

风行水上 @ 2012-11-21 12:54:47
标签:

    Tcl中的命令基本上都是可以重新定义的,包括像if、while这样的内置命令。

    但在试图实现自定义的if命令时,却发现问题没那么简单。

    % proc a {args} {puts a ; if 1 return ; puts c}
    % a
    a
    % rename if if@tcl ; proc if {args} {uplevel 1 return} ; a
    a
    c
    

    上面的例子表明,自定义的if命令不能处理return这样的命令。当然这也许是uplevel命令的问题。

    该怎么做? TODO

    标签:

      分享到:
      comments powered by Disqus

      24/28ms