proc
proc name args body
Makes a command from a body of Tcl. args is a list of the argument names. An argument {name default} has a default value, and the last argument args gets each extra word as a list. A proc of the same name replaces the earlier one.
Examples
A click on an example runs it in the shell of the page.
proc greet {who {word Hello}} {return "$word, $who"}; greet Ada:Hello, Adaproc sum {args} {tcl::mathop::+ {*}$args}; sum 1 2 3:6
Errors
greetgives the errorwrong # args: should be "greet who ?word?"
Facts
- Capability: none.
- Compute cost: one compute unit for the call, and more for the commands that it runs.