----- Original Message ----- From: "Tim Rowledge" tim@sumeru.stanford.edu To: squeak-dev@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@huv.com wrote:
On Tue, 30 Nov 2004 12:32:36 -0800, Tim Rowledge
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