Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array get "stringifies" objects in tcl8.5 but not in tcl8.4

Status
Not open for further replies.

sehmann2

Programmer
Jan 26, 2011
1
US
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);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top