Changing the class on an object

Dan Ingalls Dan.Ingalls at disney.com
Fri Aug 11 02:32:55 UTC 2000


>For some reason, I was thinking that there was a way to change the class of
>an object, but I can't seem to find it.  Is there such a thing?  I would
>like to mutate an instance of one class into an instance of another class
>without changing it's OOP.  Presumably the instance size and type of both
>classes should be the same for this to work.
>
>The key phrase is: "without changing it's OOP."  I want to avoid a costly
>become:.

Stephen -

As far as I know, there's now way to do this without changing the oop.  There is no control over what oop you get when you create a new object.  I can think of only 3 ways to go:

1.  Write a primitive that does this.

2.  Figure some truly nasty way of doing this that will stop working as soon as the security team gets farther along with their work.

3.  Use become.  I know it takes time (3ms in a 20Mb image of mostly pointers on a 400MHz Mac), but you can also do many of them at once.

	- Dan






More information about the Squeak-dev mailing list