Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d22aa6b54780e343989c1095e5e05c1109f2f92a
Ticket: 1998273fffffffffffffffffffffffffffffffff
Making a proc arg's unshared
User & Date: ferrieux on 2008-06-19 21:55:13
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Inside a proc, a value passed as argument typically has a refcount of three. Of the two unwanted ones, one is easily removed: the local var
    
             foo $x[unset x]
    
    but the other is harder: it is in the CallFrame's objv, basically [info level 0].
    
    The attached patch provides [info zaplevel] which prematurely neutralizes the [info level 0] data for that purpose. Thus, in
    
         proc pop x {
            info zaplevel
            lrange $x[unset x] 0 end-1
         }
    
    The $x value is effectively passed unshared, provided it is passed unshared by the caller.
    
    The patch works by downing the refcounts of all members of [info level 0] except the head (to keep the proc name visible, should someone call [info level 0] after [info zaplevel]), and replacing them with references to a shared empty Tcl_Obj. Hence an [info level 0] of "foo a b c" becomes "foo {} {} {}".
    This gives us safety in the event of callers cacheing CallFrame->objc,objv in locals/registers.
    
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "ferrieux"
  10. subsystem changed to: "10. Objects"
  11. title changed to: "Making a proc arg's unshared"
  12. type changed to: "RFE"