[Sc-devel] [] can cause instability: tests in primitives?
Dan Stowell
danstowell at gmail.com
Thu Nov 22 20:24:47 PST 2007
Stefan,
Thanks for this. I don't know about the issues in building the empty
arrays so if you could have a look at that, I'd be v grateful. I've
committed (svn rev 6664) the easy fix: clipAt, wrapAt, foldAt now
return nil if called on [].
Dan
2007/11/21, Stefan Kersten <sk at k-hornz.de>:
> On 21.11.2007, at 16:51, Dan Stowell wrote:
> > wrapAt's primitive uses basicWrapAt(), and plot uses unlace which uses
> > prArrayUnlace(), both in PyrArrayPrimitives.cpp. Looks like they both
> > fail to account for an empty array.
> >
> > Could there be some generic way to catch these problems? e.g. this
> > line could (I guess) return nil if empty:
> >
> > if(obj->size==0) {SetNil(a); return errNone; }
>
> yes, basicWrapAt is missing the check for obj->size == 0, also for
> the array-as-index case.
>
> > but would need slightly different versions adding to each primitive.
> > Any better way?
>
> the solution wouldn't be quite correct for unlace:
>
> [].unlace(3)
>
> [[],[],[]]
>
> i guess (jmc will correct me if i'm wrong), that the newly created
> subarrays (and the result array) need to be reconsidered by the
> garbage collector:
>
> SetObject(slots2 + i, obj3);
> g->gc->GCWriteNew(obj2, obj3);
>
> , likewise for the sublist elements:
>
> PyrSlot* tmp = slots + (i*clump + k + j*numLists);
> slots3[j+k].ucopy = tmp->ucopy;
> g->gc->GCWrite(obj3, tmp->uo);
>
> [ cannot test properly now, still at work :P ]
>
> <sk>
>
> _______________________________________________
> Sc-devel mailing list
> Sc-devel at create.ucsb.edu
> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>
--
http://www.mcld.co.uk
More information about the Sc-devel
mailing list