anObject becomeForward: aSmallInteger

Tom Phoenix rootbeer at redcat.com
Sun Jun 25 17:09:27 UTC 2006


On 6/25/06, Michael van der Gulik <squeakml at gulik.co.nz> wrote:

> Why can an object not #becomeForward to a SmallInteger? The
> primitive fails.

In performing #becomeForward:, the VM converts each pointer to object
Old into a pointer to object New. But there is no pointer to a
SmallInteger (and maybe other classes, depending upon the Smalltalk
implementation).

But in principle, the VM could certainly replace each instance of
object Old instead with a SmallInteger. It doesn't, probably because
that's not what #become: is made to do; it's made to work with object
pointers, not immediate objects.

You could use a subclass of PointerFinder to do what you want, I
think. It would need to not only find the pointer to object Old, but
replace it with whatever target value you would like, even a
SmallInteger. You'd have to use some minor magic, such as
#instVarAt:put:, but that's less likely to cause confusion compared to
the #become: family.

Good luck with it!

--Tom Phoenix



More information about the Squeak-dev mailing list