From: SourceForge.net <no...@so...> - 2011-02-01 12:25:43
|
Bugs item #3169173, was opened at 2011-01-31 23:02 Message generated for change (Settings changed) made by msofer You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=3169173&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 10. Objects Group: current: 8.5.9 >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Stephen Ehmann (sehmann) Assigned to: miguel sofer (msofer) Summary: crosstalk between arrays Initial Comment: It seems like there is some sort of cross talk between arrays. we are trying to upgrade our system from 8.4.9 to 8.5.9 and this is a blocker. proc test {} { array set foo "" array set bar "" set foo(b) a set bar(a) b foreach i [array names bar] { puts "$i : [otype $i]" } set l {} foreach {i j} [array get foo] { foreach k $j { lappend k $l } } foreach i [array names bar] { puts "$i : [otype $i]" } } test Output: a : string a : list array names is returning an element that is a list! Does not happen if we don't use the "test" proc. 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); } ---------------------------------------------------------------------- >Comment By: miguel sofer (msofer) Date: 2011-02-01 09:25 Message: Not sure about what you are trying to do, but: the type/intrep of a Tcl_Obj is just a cache optimising the representation for the *last* usage of this obj. It is *not* really a property of the Tcl_Obj, and is subject to changing (aka shimmering). In your script, let us follow what happens to 'a': set foo(b) a set bar(a) b # 'a' is just a string foreach i [array names bar] { puts "$i : [otype $i]" } # 'a' has only been ever used used as a string, still a string set l {} foreach {i j} [array get foo] { foreach k $j { lappend k $l } } # 'a' has been treated as a list by doing [foreach] on it; type is now list ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=3169173&group_id=10894 |