Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d1ac289e5790102315560113d38e7cd85214d562
Ticket: 218782ffffffffffffffffffffffffffffffffff
trace variable / upvar problem
User & Date: nobody on 2000-10-26 01:05:17
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 2110 Bug
    Version: 8.1
    SubmitDate: '1999-05-20'
    LastModified: '2000-01-20'
    Severity: LOW
    Status: Released
    Submitter: pat
    ChangedBy: ericm
    OS: All
    FixedDate: '2000-01-20'
    FixedInVersion: 8.3
    ClosedDate: '2000-01-20'
    
    
    Name:
    Greg Orchard
    
    ReproducibleScript:
    proc update {name index op} {
            puts "name $name index $index"
        }
        
        proc getUpdate {inVar} {
            upvar $inVar localVar
            set localVar 100
        }
        
        trace variable somevar w update
        getUpdate somevar(1)
    
    ObservedBehavior:
    The output from the above is:
        
        name localVar index
    
    DesiredBehavior:
    I would expect to see:
        
        name somevar index 1
        
        since "somevar" is the one variable being traced.
    
    
    
    This is actually the designed behaviour.  While it may seem obivously incorrect, consider the case in which there are two levels of upvar, and multiple traces:
    
    proc update {name index op} {
    puts "name $name index $index"
    }
    
    proc getUpdate {inVar} {
    upvar $inVar localVar
    trace variable localVar w update
    getUpdate2 localVar
    }
    
    proc getUpdate2 {inVar} {
    upvar $inVar localVar2
    set localVar2 100
    }
    
    trace variable somevar w update
    getUpdate somevar
    
    Now it is not so clear what the behaviour should be.  Which trace should fire?  what name should it be given?  If there are many levels of indirection, it could be costly to try and determine which trace should be fired with which variable name.  And because all of the variable names actually refer to the same object, it is least confusing to fire all of the traces with the name used to trigger the trace.
    
    - eric
    
    -- 01/20/2000 ericm
    
    
    
  4. foundin changed to: "obsolete: 8.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "07. Variables"
  10. title changed to: "trace variable / upvar problem"
  11. type changed to: "Bug"