[squeak-dev] Circular definitions of size and do:
rpolkinghorne at groupwise.swin.edu.au
Fri Sep 30 02:22:17 UTC 2011
I wanted an array that lazily initialized elements 1 to n when you
asked for the nth one. So I ran something like:
SequenceableCollection variableSubclass #Foo ...
When I started a workspace, and tried Foo new: 10, my image hung.
Eventually, I found the problem. The workspace tried to print the
answered instance, which resulted in it being sent a do: message to
print its elements. This ran the method
1 to: self size do:
[:index | aBlock value: (self at: index)]
| tally |
tally := 0.
self do: [:each | tally := tally + 1].
which sent do:, which sent size, which ...
Is this considered a bug, or a learning experience for new players?
ArrayedCollection avoids it by restoring the primitive method for
More information about the Squeak-dev