What's wrong with this code, why isn't the variable arrchnck($chan:$bjmask) being unset ?
It's always incremented .... it never gets unset 4 seconds later.
note: bigjointimer is declared as a global variable.
set bigjointimer($chan) [utimer 4 { unset arrchnck($chan:$bjmask) }]
Tcl doesn't evaluate code within curly braces unless you pass it to a command that evaluates it. It would need to do this on the spot to function with the variables.
Is it nessesery to unset all variables used in a tcl procedure like in other program languages or where in execution procedure is leaved variables is all unset automatically?
A variable exist only while its parent function is active.
Global variables (global is treated like a procedure in Tcl, though one your return, it exits), exist while global is running.
Anything in a procedure is created when needed, and destroyed on exit of the procedure.
Though, obviously, if you create a variable in a procedure, that you have declared as global, the global environment becomes the parent. This means it is only destroyed on exiting global.
The exception to the above, is specificly killing a variable using unset.