Reflection about allInstances
Mathieu
mathk.sue at gmail.com
Thu Sep 7 22:48:59 UTC 2006
Hi,
I was thinking about what happen if we do:
Array allInstances
Beceause #allInstances return an Array but this array are not include in himself.
So #allInstances don't really return all instances?
So after I have investigated allInstances and have discovered that the array was created at the end
of the method. But an other question come out.
I have saw in the object return by 'Array allInstances' that at the end many array look like the one
return by 'Array allInstances'.
Hope you follow up to now. :)
So I was wondering why. And I have look the implementation of OrderedCollection and saw that it use
Array to store the elements.
So If we don't want the element create during the execution of allInstances, the one inside the
OrderedCollection shouldn't appear?
| all |
all _ OrderedCollection new.
self allInstancesDo: [:x | x == all ifFalse: [all add: x]].
^ all asArray
"x == all" it's not enough. It should be something like :
"all allDeepInstVar includes: x" (#allDeepInstVar dose not exist)
I know that may not be very important but what do you think?
Math
More information about the Squeak-dev
mailing list
|