Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-15
11:29 • Closed ticket [3599017fff]: trace that unsets and then sets and array plus 3... artifact: 297d2d16e5 user: serhiy.storchaka
2013-01-03
03:12 • Pending ticket [3599017fff]. artifact: 116daecac1 user: dgp
03:04 • Ticket [3599017fff]: 4 changes artifact: 67e31eff5f user: dgp
2012-12-31
16:19 • New ticket [3599017fff]. artifact: fa62c95c09 user: pooryorick

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.