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

Rob Withers reefedjib at
Mon Nov 5 17:39:29 UTC 2007

What gaurantees that doing loops with #nextObject won't cause cyclic looping 
whereby you process the same set of objects over and over again?

The work I was doing was testing changing the parser to eliminate #ifTrue: 
macros from compiled methods and recompiled the entire image.  I saved the 
image.  When I started the image it was frozen.  I broke into it and it was 
looping in the method CommandHistory class>>#forgetAllGrabCommandsFrom:.  I 
took the loop and modified it slightly to see what it was processing:

    | 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].

It was looping through objects defined by this loop, block contexts defined 
by my change to #ifTrue: bytecodes - they now create block contexts.

[] in UndefinedObject>>DoIt {[object removeProperty: #undoGrabCommand]}
[] in UndefinedObject>>DoIt {[count > 500000]}
[] in OrderedCollection>>addLast: {[self makeRoomAtLast]}
[] in UndefinedObject>>DoIt {[object removeProperty: #undoGrabCommand]}
[] in UndefinedObject>>DoIt {[count > 500000]}
. . .

What guarantee is there supposed to be that #nextObject won't loop back into 
a cycle?  What did I do to break that guarantee and how can I reestablish 


More information about the Squeak-dev mailing list