|
From: Alexandre F. <ale...@gm...> - 2008-01-17 00:26:56
|
On 1/17/08, miguel sofer <mig...@gm...> wrote:
> >
>
> Hey Alex.
>
> I now saw that you want a List obj after Tcl_SetListObj with no
> elements? No need to shimmer then using the setFromAnyProc!
>
> Just call Tcl_SetListObj(objPtr, 1, NULL) and you've got it! Trick is
> the same as with Tcl_NewListObj: objc>0 forces List internal rep, if
> objv is NULL then the list will be allocated to be able to hold objc
> elements (maxElemCount=objc), but will be initialized as empty
> (elemCount=0).
Sorry I was unclear :-)
In fact I'm *inside* the Tcl_SetListObj() function, which most of the
time calls NewListIntRep(), but in the special case objc==0, just zaps
to a "". So what I did was refine the "if (objc>1)" test to "if
((objc > 0)||wasMutable)", and then clip the arguments to
NewListIntRep to have 1 elem at least:
if ((objc > 0)||wasMutable) {
listRepPtr = NewListIntRep((objc==0)?1:objc,(objc==0)?NULL:objv);
this way, as you suggested, I always have a place to propagate the
mutable flag of the old list :-)
> PS: if/when you get around to it, I'd be mightily interested in the
> semantics of what you are trying to do. Can't have an opinion or help in
> implementation until I understand ... and that thread on clt was just
> too much. If you ever summarize it ...
Look near the end, I have tried to illustrate the script-level aspects:
http://groups.google.com/group/comp.lang.tcl/tree/browse_frm/thread/b6c26a33f5ebd3e0/c8c452ad6386d7b2?hl=en&rnum=91&_done=%2Fgroup%2Fcomp.lang.tcl%2Fbrowse_frm%2Fthread%2Fb6c26a33f5ebd3e0%3Fhl%3Den%26#doc_5966ecb98c4ad8a6
-Alex
|