[squeak-dev] The Trunk: System-cwp.660.mcz

Bert Freudenberg bert at freudenbergs.de
Thu Jan 9 10:14:15 UTC 2014


On 09.01.2014, at 07:55, Levente Uzonyi <leves at elte.hu> wrote:

> On Thu, 9 Jan 2014, commits at source.squeak.org wrote:
> 
>> Colin Putney uploaded a new version of System to project The Trunk:
>> http://source.squeak.org/trunk/System-cwp.660.mcz
>> 
>> ==================== Summary ====================
>> 
>> Name: System-cwp.660
>> Author: cwp
>> Time: 8 January 2014, 9:02:53.874 pm
>> UUID: 3fb6a88d-86cf-4625-b7b5-e59a476195b3
>> Ancestors: System-cwp.659
>> 
>> Add a test for 0 in #allObjectsDo:, as it's possible for the sentinel object not to be enumerated.
> 
> How can that happen?
> 
> 
> Levente

Maybe if inside aBlock you #become: the current object to one newer than lastObject?

Of course, in that case you wouldn't enumerate all objects, so you shouldn't do that. If that's the case you want to solve, then reaching 0 should raise an error. Something like

 	[lastObject == object]
		whileFalse: [
			aBlock value: object.
			(object := object nextObject) == 0 ifTrue: [
				^self error: 'should not happen']]!


which would be better than an infinite loop.

- Bert -


> 
>> 
>> =============== Diff against System-cwp.659 ===============
>> 
>> Item was changed:
>> ----- Method: SystemNavigation>>allObjectsDo: (in category 'query') -----
>> allObjectsDo: aBlock
>> 	"Evaluate the argument, aBlock, for each object in the system
>> 	excluding SmallIntegers. With closures, this needs to use an end
>> 	marker (lastObject) since activation of the block will create new
>> 	contexts and cause an infinite loop."
>> 	| object lastObject |
>> 	object := self someObject.
>> 	lastObject := Object new.
>> + 	[lastObject == object | object == 0]
>> - 	[lastObject == object]
>> 		whileFalse: [aBlock value: object.
>> 			object := object nextObject]!
>> 
>> 
>> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4142 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140109/67371846/smime.bin


More information about the Squeak-dev mailing list