Skip to content
Tcl Source Code View Ticket
Login

View Ticket

trace that unsets and then sets and array

Closed / Wont Fix3599017fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 49 days ago
Descriptionplain2012-12-31 16:19:07
In the following example, the asnwer to [info exists ::var1] is "1", but the answer to [info exists var2(1)] is "0".  Is this not inconsistent?

set ::var1 [list 1 v1]
trace add variable ::var1 {read} ::trace1
proc trace1 { args } {
unset ::var1
set ::var1 [list 1 v1]
}
puts [info exists ::var1]

array set ::var2 [list 1 v1]
trace add variable ::var2 {read} ::trace2
proc trace2 { args } {
array unset ::var2
array set ::var2 [list 1 v1]
}

puts [info exists ::var2(1)]
dgpplain2013-01-03 03:04:31
The problem is not just consistency, but how that
consistency came to be, whether by intent or accident,
and what code out there relies on current behavior (think Tk).

That said, it might be interesting to see what happens if
TclVarTraceExists() makes another TclLookupVar() call
after traces complete.
dgpplain2013-01-03 03:12:19
The same "inconsistency" is present back in Tcl 7.6.

Whatever might arguably be "right", the stable choice
is not to mess with this in the Tcl 8 time frame.
serhiy.storchakawiki2026-10-15 11:29:05

Closing: decided above.

Log in (anonymous is fine) to add a comment.