Defaulted arguments, if any, must be the last arguments for the procedure. If a default is not specified, the argument is required. The following example is provided for clarification:
proc my_incr {value {increment 1}}{
expr $value + $increment
}
my_incr 42 3
—>45
my _ incr 42
—>43
proc my_incr {{increment 1} value}{
expr $value + $increment
my _ incr 3 42
—>45
my_incr 42
—>Error: no value given for parameter "value" to "my_incr"
Global and local variables
A namespace is an encapsulation of commands and variables to avoid interference with other namespaces
- Procedure names are global
- Viriables inside procedures are local
- Viriiables defined outside of any procedures are global
- Global variables not automatically visible inside procedures. They are accessed inside the procedure, using the following command
->> global varnamel varname2 …