array get converts objects in the array into strings. This is happening to our other objects as well, not just lists.
Does anyone know where I can read the details of this behavior change?
Does anyone know the reason for this change? Seems like a step backwards...
8.4.9:
% array set arr [list a 1 b 2 c [list 3] d [list 4 5]]
% foreach a [array names arr] { puts [otype $arr($a)]}
list
string
string
list
% set al [array get arr]
d {4 5} a 1 b 2 c 3
% foreach a $al { puts [otype $a]}
string
list
string
string
string
string
string
list
%
8.5.1 and 8.5.9:
% array set arr [list a 1 b 2 c [list 3] d [list 4 5]]
% foreach a [array names arr] { puts [otype $arr($a)]}
list
string
string
list
% set al [array get arr]
d {4 5} a 1 b 2 c 3
% foreach a $al { puts [otype $a]}
string
string
string
string
string
string
string
string
%
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);
}
Does anyone know where I can read the details of this behavior change?
Does anyone know the reason for this change? Seems like a step backwards...
8.4.9:
% array set arr [list a 1 b 2 c [list 3] d [list 4 5]]
% foreach a [array names arr] { puts [otype $arr($a)]}
list
string
string
list
% set al [array get arr]
d {4 5} a 1 b 2 c 3
% foreach a $al { puts [otype $a]}
string
list
string
string
string
string
string
list
%
8.5.1 and 8.5.9:
% array set arr [list a 1 b 2 c [list 3] d [list 4 5]]
% foreach a [array names arr] { puts [otype $arr($a)]}
list
string
string
list
% set al [array get arr]
d {4 5} a 1 b 2 c 3
% foreach a $al { puts [otype $a]}
string
string
string
string
string
string
string
string
%
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);
}