I'm getting this weird issue. i'm using tcl 8.3
after i define this proc in a tcl shell
% proc incr { varName {amount 1}} {
puts $varName
upvar #0 $varName var
puts $varName
if {[info exists var]} {
set var [expr $var + $amount]
} else {
set var $amount
}
return $var
}
i keep getting
%
history(nextid)
history(nextid)
history(oldest)
history(oldest)
%
Everytime i hit newline "Enter" after that any one has any idea why this is happening?
Because the history managment is written in Tcl itself, and that uses
incr.Your
incris almost equal to Tcl 8.3'sincrwith some differences:So if you remove the first difference (the
puts) everything will work as expected, just that some library commands may call yourincrinstead the standardincr.The second difference is now in the core, IIRC starting with Tcl 8.5 it is not nessencary that a variable already exists pior to calling
incr.In short: What you did is fine. But don't expect to be the only one who calls an standard command.