Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 12b248242bae63e067c6f375082964625ab64549
Ticket: 651271ffffffffffffffffffffffffffffffffff
trace add command doesn't qualify names
User & Date: nobody on 2002-12-10 04:37:56
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    The new "trace add command" either has a bug or isn't
    very useful,
    one or the other.  Consider this example:
    
    proc foo {} {puts "Foo!"}
    
    proc tracer {old new op} {
        puts "traced $old $new $op"
     }
    
    trace add command foo rename tracer
    
    namespace eval my_ns { rename foo bar }
    
    This outputs
    
    traced foo bar rename
    
    Now, in fact, command ::foo is being renamed ::my_ns::bar.
    If I'm really using this trace for anything but debugging,
    I need to know that.  So how do I find out?  My first
    thought
    was this, using "namespace which":
    
    proc tracer {old new op} {
        set uold [uplevel namespace which -command $old]
            set unew [uplevel namespace which -command $new]
    
        puts "traced $old=$uold $new=$unew"
    }
    
    I was hoping that running the same case as above, I'd get
    this output:
    
    traced foo=::foo bar=::my_ns::bar
    
    Instead, I got
    
    trace foo=::my_ns::bar bar=::my_ns::bar
    
    This isn't entirely unreasonable; it simply means that
    that the command has already been renamed when "tracer"
    is called.  In a way, it's surprising that I get a
    result for "foo" at all.
    
    I finally found a workaround...but gosh, I shouldn't
    have to do that 
    much work.  The "rename" command obviously has to
    qualify the
    proc names to do its job; it seems completely unreasonable
    that it doesn't pass that information along to the
    callback.
    
    Will Duquette
    
  4. foundin changed to: "obsolete: 8.4.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: "18. Commands M-Z"
  10. title changed to: "trace add command doesn't qualify names"
  11. type changed to: "Bug"