Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c02aaae0b6ca3e80e965954a143aa125d5693b3d
Ticket: 2014921fffffffffffffffffffffffffffffffff
list from dict or "array get" loses internal representations
User & Date: cjmcdonald on 2008-07-10 10:56:37
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Accessing a dict Tcl_Obj as a list loses the internal representations of all of the element Tcl_Objs.  This is because the list object is rebuilt in SetListFromAny from the dict string representation.
    
    In Tcl 8.5 "array get" has been modified to return a dict object.  A consequence of this is that the following code now loses all of the internal representations of the aname and avalue elements.
    
        # Process all array elements.
        
        foreach {aname avalue} [array get arrayVariable] {
        # Do something with $aname & $avalue.    
        }
        
    This is a very common idiom (at least in my code!), and corresponds to examples on the array man page and in various Tcl books.  So we have something of a performance regression from Tcl 8.4.
    
    The problem can be avoided by modifying all such usage to "dict for".  However, that is rather obscure, particularly as the array man page only talks about lists and not dicts.  I think that it would be good if SetListFromAny could recognise and process a dict object in such a way as to preserve the element Tcl_Objs.
    
  4. foundin changed to: "obsolete: 8.5.3"
  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: "cjmcdonald"
  10. subsystem changed to: "15. Dict Object"
  11. title changed to:
    list from dict or "array get" loses internal representations
    
  12. type changed to: "Bug"