Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 31b5928c23fcbf4ee939993e2a55c8fb8a0fb839
Ticket: 57e44de76e71ba13b896571404da2451fcc6c4f1
Array Read Trace fires only if Array has been written to
User & Date: venkat on 2015-07-05 20:07:16
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    === start of a.tcl ===
    
    proc ::stracer {junk var op} {
        if {$var == ""} return
        switch $op {
            r {
                puts "Read Fired"
                set ::a($var) 5
            }
            w {
                puts "Write Fired"
            }
        }
    }
    
    trace variable ::a rw ::stracer
    
    # set a(test2) 5
    puts "$a(test1)"
    
    === end of a.tcl ===
    
    Running:
    
    % tclsh8.6 a.tcl
    can't read "a(test1)": no such variable
        while executing
    "puts "$a(test1)""
        (file "a.tcl" line 17)
    
    
    Now remove the commented line (Remove # in "# set a(test2) 5)
    
    % tclsh8.6 a.tcl
    Write Fired
    Read Fired
    5
    
    ----
    
    Why does the write to the array change the behaviour of the read trace?
    
  5. foundin changed to: "8.6.4"
  6. is_private changed to: "0"
  7. login: "venkat"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "1fb8c275493b1f1dcf8db46d6d541794a011947f"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "venkat"
  14. subsystem changed to: "07. Variables"
  15. title changed to:
    Array Read Trace fires only if Array has been written to
    
  16. type changed to: "Bug"