tcl中proc语法的几种风格有什么区别?

Oli*_*One 0 syntax tcl

我可以知道proc的sytanx是如何工作的.在...的背景下

- 记忆消费

- 传播

-scope of proc(本地/全球)

proc dosomething {} {
   #code here
}

proc dosomething { } {
    #code here
}

proc dosomething {
    #code here
}

proc dosomething args {
     #code here
}

proc ::dosomething {} {
     #code here
}
Run Code Online (Sandbox Code Playgroud)

等等.....

RHS*_*ger 5

它们大致相同:

定义不带参数的命令

proc dosomething {} {
   #code here
}
Run Code Online (Sandbox Code Playgroud)

与上面相同,定义了一个没有参数的命令

proc dosomething { } {
    #code here
}
Run Code Online (Sandbox Code Playgroud)

无效......应该抛出错误

proc dosomething {
    #code here
}
Run Code Online (Sandbox Code Playgroud)

定义具有可变数量参数的命令(即varargs)

proc dosomething args {
     #code here
}
Run Code Online (Sandbox Code Playgroud)

在顶级命名空间中定义一个没有参数的命令(在大多数情况下与前两个相同)

proc ::dosomething {} {
     #code here
}
Run Code Online (Sandbox Code Playgroud)

顺便说一句,没有本地程序.它们可以位于命名空间内,但所有过程都是全局的.