From: Kevin K. <kev...@gm...> - 2010-02-03 00:59:00
|
Andy Goth wrote: > (Is this the right forum for this type of discussion?) > > I believe it is possible to merge the list and dict Tcl_Obj types > such that a dict is simply a list whose intrep contains some extra > indexing information; dict extends list without replacing it, like > a subclass. This change can be made without affecting script-level, > API-level, or even binary-level compatibility. The only observable > difference should be a performance improvement in some circumstances > from reduced shimmering. Uhm. Is it time to mention Feather again? Some of Feather's ideas were - after sober thought - very bad ones. But I rather liked its idea that Tcl_ObjTypes could have inheritable interfaces. It would be a Very Good Thing if [dict for], the [array startsearch] stuff, and [foreach] could be unified. It would be a Very Good Thing if [dict keys] and [array keys] could return some sort of iterator, and not have to construct a list (particularly since their commonest use is as the list argument of [foreach]. And (in Tcl 9 territory, because we'd have either to grow Tcl_ObjType by at least one word or else result to an ugly kludge like the one Paul Duffin came up with), I think unified containers would make sense. -- 73 de ke9tv/2, Kevin PS: (The one I want is a sorted list or map, allowing for duplicate keys, and supporting O(logN) time for insertion (by key and perhaps position within equal keys, search by key, search by numeric position, and split (destructive [lrange]). It's amazing how useful such a structure is if done right. |