Tcl Source Code

View Ticket
Login
Ticket UUID: 309cfea3a209993f055e966c436bc16746f7f8e8
Title: Append does not trigger variable read traces
Type: Bug Created on: 2023-10-03 15:46:41
Submitter: ambaker1 Assigned to: nobody
Subsystem: 07. Variables Severity: Important
Priority: 5 Medium Last modified: 2026-05-24 00:56:42
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: 8.6.10
Description:

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
User Comments:
apnadkarni added on 2026-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.