Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b297d2badf8ef3d192fd6ec86ea1af1fd7c58020
Ticket: 3169002fffffffffffffffffffffffffffffffff
conversion from "dict" to "list" loses object types
User & Date: sehmann on 2011-02-01 05:30:37
Changes

  1. icomment:
    It prints the right thing... Hmm...
    % array set a ""
    % set a(b) "1"
    1
    % set a(c) [list 1 2]
    1 2
    % set l [array get a] ; foreach key $l { puts "[otype $key]" }
    string
    int
    string
    list
    
    But separating them does not:
    % array set a ""
    % set a(b) "1"
    1
    % set a(c) [list 1 2]
    1 2
    % set l [array get a]
    b 1 c {1 2}
    % foreach key $l { puts "[otype $key]" }
    string
    string
    string
    string
    
    Why would list operations behave ok in this regard?
    % set l [list 1 [list 1 2]]
    1 {1 2}
    % otype $l
    list
    % otype [lindex $l 0]
    int
    % otype [lindex $l 1]
    list
    %
    
    
    I forgot to add that otype is a C function we wrote to print the type of the object and is implemented like this:
        if ( obj->typePtr ) {
            char* typeName = obj->typePtr->name;
            Tcl_SetResult(interp, typeName, TCL_VOLATILE);
    
        } else if ( obj->bytes ) {
            Tcl_SetResult(interp, (char*)"string", TCL_STATIC);
    
        } else {
            Tcl_SetResult(interp, (char*)"unknown", TCL_STATIC);
        }
    
    
  2. login: "sehmann"
  3. mimetype: "text/plain"
  4. username: "sehmann"