cyclic looping with [0 == object] whileFalse: [object := objectnextObject].

Rob Withers reefedjib at yahoo.com
Mon Nov 5 18:54:10 UTC 2007


----- Original Message ----- 
From: "Tom Phoenix" <rootbeer at redcat.com>
To: "The general-purpose Squeak developers list" 
<squeak-dev at lists.squeakfoundation.org>
Sent: Monday, November 05, 2007 10:40 AM
Subject: Re: cyclic looping with [0 == object] whileFalse: [object := 
objectnextObject].


> On 11/5/07, Rob Withers <reefedjib at yahoo.com> wrote:
>
>>     | object count objects |
>>     objects := OrderedCollection new: 1000000.
>>     count := 0.
>>     object _ nil.
>>     [0 == object or: [count > 500000]] whileFalse: [
>>         count := count + 1.
>>         objects add: object.
>>         object isMorph ifTrue: [object removeProperty: #undoGrabCommand].
>>         object _ object nextObject].
>>     objects
>
> Now that I look at this code again, I see more. (What's the last line
> supposed to be doing?) The method looks to be building a collection of
> all (or up to half a million) objects in object memory, for no
> apparent reason. As a side effect, or maybe its main effect, it
> affects some Morphs.

This was only my method of detecting whether there was a cycle in the 
objects it was processing.  That's all.  Now why they don't just do:

>  Morph allSubInstancesDo: [:m |
>    m removeProperty: #undoGrabCommand ].

in #forgetAllGrabCommandsFrom: in the first place, I don't know.

Beyond this instance of using #nextObject to loop, it seems that if objects 
are created inside of that loop, then it may loop forever.

Cheers,
Rob 




More information about the Squeak-dev mailing list