Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 11ef0939104cd9554f1c46c05b210710cc461e85
Ticket: ace7bf3dcff30d649961bcabd4caea48a1ac0b49
trace on upvar'd arrays appears inconsistent
User & Date: cmcc on 2014-05-25 21:52:17
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    Per the code below, I would have expected the upvar'd element modification to trigger the array trace as well as the element trace.  I accept that this may be a lot of work and complexity for what is a corner case.  I suggest that the documentation specify the behaviour in this case.
    
    variable V; array set V {}
    
    proc eincr {} {
        upvar #0 V(a) a
        incr a
    }
    
    proc aincr {} {
        upvar #0 V V
        incr V(a)
    }
    
    proc varmod {args} {
        puts stderr "varmod: $args"
    }
    
    ::trace add variable V(a) {write unset} [list varmod element]
    ::trace add variable V {write unset} [list varmod array]
    
    puts stderr "global set"
    set V(a) 1	;# triggers array and element traces
    
    puts stderr "upvar array element set"
    aincr		;# triggers array and element traces
    
    puts stderr "upvar element set"
    eincr		;# triggers only element trace
    
  5. foundin changed to: "8.6"
  6. is_private changed to: "0"
  7. login: "cmcc"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "16910d69b11045755316a073070779a85cd9218f"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "cmcc"
  14. subsystem changed to: "46. Traces"
  15. title changed to: "trace on upvar'd arrays appears inconsistent"
  16. type changed to: "Patch"