Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 91d0711c7afe04f872d51a14288b7e9800c728b7
Ticket: 862526872cda074626d8a1e020479acf44ed7009
Getting another object of the same type in dict and list for performance
User & Date: anonymous on 2015-04-20 17:44:24
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    When getting an element of a list using "lindex" or getting an element of a dict using "dict get", the procedure returns a string.
    
    In the situation that some user wants to traverse recursively this data structure, or wants simply a subnode of this data structure for processing he has to convert the string into a dict or a list again.
    
    I would be nice a subcommand similar to this:
        - dict subnode key? key? key? ...
        - list subnode key? key? key? ...
    
    This subcommand returns the subnode with the same type as the container for that key. I mean that "dict subnode" should returns another dict and "list subnode" another list.
    
    This new subcommand would be interesting for performance manipulating complex data structures.
    
    This script shows that "dict get" and "lindex" returns a string object instead of a dict or list object:
    
    set a [list 1 2 {1 1 2332 {12 12} } 23]
    puts "a inner representation: \n\t[::tcl::unsupported::representation $a]\n"
    
    set b [lindex $a 2]
    puts "b inner representation: \n\t[::tcl::unsupported::representation $b]\n"
    
    set c [dict create key1 val1 key2 {key21 val21 key22 {key221 val221} } key3 val3]
    puts "c inner representation: \n\t[::tcl::unsupported::representation $c]\n"
    
    set d [dict get $c key2 key22]
    puts "d inner representation: \n\t[::tcl::unsupported::representation $d]\n"
    
  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:
    Getting another object of the same type in dict and list for performance
    
  16. type changed to: "Bug"