Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ff30d99c2483b425599b806c8c4a4ff81bc45e48
Ticket: 1998273fffffffffffffffffffffffffffffffff
Making a proc arg's unshared
User & Date: ferrieux on 2008-06-20 05:32:53
Changes

  1. icomment:
    Logged In: YES 
    user_id=496139
    Originator: YES
    
    No. [take x] is exactly the same as $x[unset x], but in less efficient ;-)
    
    To witness that you still have an extra ref:
    % proc K {x y} { set x }
    % proc take {v} { upvar 1 $v x ; K $x [unset x] }
    % proc pop x {lrange [::tcl::unsupported::debugobj [take x]] 0 end-1}
    % pop [list d f g h]
    Obj:0x9F2340(2) (list):0x9F1000-0x0 <<<?>>>
    d f g
    
    Now with [info zaplevel]:
    % proc pop x {info zaplevel;lrange [::tcl::unsupported::debugobj [take x]] 0 end-1}
    % pop [list d f g h]
    Obj:0x9DB658(1) (list):0x9EF4C8-0x0 <<<?>>>
    d f g
    
    PS: A side note: the $x[unset x] idiom is the K-free K given to me by Kevin IIRC. It is very efficient because the concatenation of the empty string has a shortcut and causes no duplication nor shimmering.
    
    
  2. login: "ferrieux"
  3. mimetype: "text/plain"
  4. username: "ferrieux"