Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5ba44d1c5be84f7d639af1f5f7b0341ebfeb344a
Ticket: 9ec7bd5f329df1ff790266b3c318a837ac32895e
Some way to modify complex data structures efficiently
User & Date: anonymous on 2015-05-09 04:40:48
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    It seems that TCL can only tackle efficiently complex data structure that are only composed of lists or only composed of dicts. But when there is a mix of data structures (lists and dicts) and it's necessary to modify an internal node, TCL makes a copy and modifies that copy, instead of modify directly the internal node.
    
    Here there is an example:
    
    
    set complex_datastructure [dict create a b c [list 1 2 3]]
    
    # We get the list inside the dict
    set subnode [dict get $complex_datastructure c]
    
    # We retrieve the internal representation and we observe that subnode is a list. The pointer reference is 0x98c1270.
    puts [tcl::unsupported::representation $subnode]
    
    # Return value: value is a list with a refcount of 3, object pointer at 0x98b6f08, internal representation 0x98c1270:(nil), no string representation
    
    # We change the subnode
    lset subnode 0 10
    
    # We get the internal representation again but the pointer reference is different: 0x98b7838!
    puts [tcl::unsupported::representation $subnode]
    
    # Return value: value is a list with a refcount of 2, object pointer at 0x98b7838, internal representation 0x98caa40:(nil), no string representation
    
    
    # The pointer of the original data structure subnode is the same as the begining. It didn't change: 0x98c1270
    puts [tcl::unsupported::representation [dict get $complex_datastructure c]]
    
    # Return: value is a list with a refcount of 2, object pointer at 0x98b6f08, internal representation 0x98c1270:(nil), no string representation
    
  5. foundin changed to: "8.6"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "1c4b6cdb98c9dfc4d1e74018f3f4efa00ad217e2"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "- New Builtin Commands"
  15. title changed to:
    Some way to modify complex data structures efficiently
    
  16. type changed to: "Bug"