Append does not trigger variable read traces
Open309cfea3a209993f055e966c436bc16746f7f8e8Created 3 years agoUpdated 193 days ago
Descriptionmarkdown2023-10-03 15:46:41
The "append" command does not trigger variable read traces.
# Bug with read trace with Tcl append command.
proc ReadTrace {name1 name2 op} {
upvar 1 $name1 var
set var foo
}
trace add variable x read ReadTrace
# lappend triggers the read-trace, modifying x before writing to it.
set x hello
puts [lappend x bar]; # foo bar
# lset triggers it as well.
set x hello
puts [lset x end+1 bar]; # foo bar
# append, on the other hand, does not trigger the read trace.
set x hello
puts [append x { bar}]; # hello bar
puts $x; # foo
apnadkarnimarkdown2026-05-24 00:56:42
I'm not sure I see the problem. I get the following (8.6.17) running the above script.
foo bar
foo bar
hello bar
foo
Looks ok to me.
Log in (anonymous is fine) to add a comment.