Dear list
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
SequenceableCollection>>do: aBlock
1 to: self size do:
[:index | aBlock value: (self at: index)]
which ran
Collection>>size
| tally |
tally := 0.
self do: [:each | tally := tally + 1].
^ tally
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
size.
Rodney