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

Jon Hylands jon at huv.com
Tue Nov 30 21:29:55 UTC 2004


On Tue, 30 Nov 2004 12:32:36 -0800, Tim Rowledge <tim at sumeru.stanford.edu>
wrote:

> Can anyone explain the VA primitive mentioned?

Here's what the code looks like:

ArrayedCollection >> #do: aBlock
	"Iteratively evaluate the one argument block, aBlock using
	 each element of the receiver, in order.
	 Fail if aBlock is not a one argument block."

	aBlock apply: self from: 1 to: self size.

--------------

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

Later,
Jon

--------------------------------------------------------------
   Jon Hylands      Jon at huv.com      http://www.huv.com/jon

  Project: Micro Seeker (Micro Autonomous Underwater Vehicle)
           http://www.huv.com



More information about the Squeak-dev mailing list