|
From: miguel s. <mig...@gm...> - 2008-01-16 23:09:21
|
Alexandre Ferrieux wrote: > Hello, > > While implementing mutability, I realize that the empty list at some > places (notably when doing Tcl_SetListObj with no elements) is not a > list at all, it's just an object with an empty string rep and a NULL > type. > > That NULL type is nasty for me, because so far I relied on the intrep > to store the mutable flag (I don't want to increase the size of > Tcl_Objs). > > Now, I could handle that case differently if I could find an unused > field in Tcl_Obj's of NULL type (pure strings). Is there one ? Is the > internalRep.twoPtrValue.ptr(1 or 2) usable for this purpose to denote > the fact that a NULL-type object is mutable ? > > (BTW it's primarily intended for mutable empty lists, but could be > generalized to mutable strings) Those fields are typically filled with garbage, so they will not really be usable. Except if you start setting them to NULL at each Tcl_NewObj. Probably not a great idea. But ... Before setting the mutable flag on an empty list, you can force shimmering to listType using tclListType's setFromAnyProc. After that you have a List internal rep, and you can do your thing. If this is a completely new empty list, a call to Tcl_NewListObj(1,NULL) will give you back an empty list with List internal rep - empty but with enough space allocated for 1 element. HTH Miguel |