But by iterating over all small integers, are you not "instantiating" ones that were not in use? Dr. Heisenberg will get a good grin out this one :)
________________________________________ From: [email protected] [[email protected]] On Behalf Of Eliot Miranda [[email protected]] Sent: Sunday, November 21, 2010 6:10 PM To: [email protected] Subject: Re: [Pharo-project] is there an easy way to know the SmallInteger instances? So you could implement SmallInteger class>>instanceCount ^self maxVal - self minVal + 1 SmallInteger class>>allInstances ^self minVal to: self maxVal you could implement the following but it's of academic interest only; it'll take a long time on a 64-bit implementation ;) If you add this then you have to guard against it being invoked because shure as s**t someone will wonder why the system isn't doing anything when they ask some apparently reasonable question about instance counts... SmallInteger class>>allInstancesDo: aBlock self minVal to: self maxVal do: aBlock best Eliot
