tags:

views:

54

answers:

1

Hello, May I know how sytanx of proc affets on its working. in context of

-Memory consumption

-Argument passing

-scope of proc (local/global)

proc dosomething {} {
   #code here
}

proc dosomething { } {
    #code here
}

proc dosomething {
    #code here
}

proc dosomething args {
     #code here
}

proc ::dosomething {} {
     #code here
}

And so on.....

+5  A: 

They are mostly the same:

Defines a command with no arguments

proc dosomething {} {
   #code here
}

Same as above, defines a command with no arguments

proc dosomething { } {
    #code here
}

Not valid... should throw an error

proc dosomething {
    #code here
}

Defines a command with a variable number of arguments (ie, varargs)

proc dosomething args {
     #code here
}

Defines a command, in the top level namespace, with no arguments (same as the first two in most cases)

proc ::dosomething {} {
     #code here
}

There's no such thing as a local proc, btw. They can be inside a namespace, but all procs are global.

RHSeeger