Adding loop primitives/optimizations (was Making Set/Dictionaryetc. loops more robust)

Joshua Scholar jscholar at access4less.net
Wed Dec 1 19:30:25 UTC 2004



----- Original Message ----- 
From: "Tim Rowledge" <tim at sumeru.stanford.edu>
To: <squeak-dev at lists.squeakfoundation.org>
Sent: Tuesday, November 30, 2004 4:28 PM
Subject: Re: Adding loop primitives/optimizations (was Making
Set/Dictionaryetc. loops more robust)


> Jon Hylands <jon at huv.com> wrote:
>
> > On Tue, 30 Nov 2004 12:32:36 -0800, Tim Rowledge
<tim at sumeru.stanford.edu>
> > wrote:
> >
> > > Can anyone explain the VA primitive mentioned?
> >
> > BlockContext >> #apply: aCollection from: start to: end
> > "Evaluate the receiver for each variable slot of aCollection from
> > start to end.  Answer aCollection."
> >
> > <primitive: VMprBlockContextApplyFromTo>
> > start to: end do: [:i | self value: (aCollection basicAt: i)].
> > ^aCollection
> Ah, I see. So I guess that OrderedCollection does it in two slices if
> the start/stop have wrapped around in stacklike usage. Fair enough but
> unless there is some hidden trickery it will only save the time in the
> to do: and basicAt: which isn't a lot. Hmm, I suppose one could use the
> prim to set some lock on the collection while one is iterating.
> Problematic if the block code modifies the collection.
>
> tim


Since I was only talking about iterating over primitive types like arrays,
it's not possible to change the size of the collection while iterating over
it.  And changing the value of individual elements wouldn't be a problem.

Joshua Scholar




More information about the Squeak-dev mailing list