Changing the Class of an Object
spair at advantive.com
Thu Dec 14 04:06:37 UTC 2000
Here's a change set that will do the trick...you'll need to compile a new
VM. It adds a method Object>>class:
This was based on some other work involving explicit metaclass
programming...can't remember who it was though.
> -----Original Message-----
> From: Andrew P. Black [mailto:black at cse.ogi.edu]
> Sent: Wednesday, December 13, 2000 8:08 PM
> To: Squeak Mailing List
> Subject: Changing the Class of an Object
> I've been looking at porting to Squeak some cunning code written by
> Stephane Ducasse. The idea is to intercept messages sent to a
> particular object by creating for that object a rudimentary class
> (actually a subclass of Behavior) that inherits from the objects real
> class but has new definitions for the intercepted messages. These
> definitions can do super-sends to get the normal behavior.
> The question that I have is: is there a way in Squeak to change the
> class of an object, the equivalent of IBM Smalltalk's fixClassTo:
> The only way that I know of doing this would be to make a new object
> that is an instance of the desired class, copy the slots, and use
> become:. But this is obviously very expensive! What I would like to
> do is just "overwrite the class pointer". But I can't see a way of
> getting at it.
> Any suggestions?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 9347 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20001213/ebf64e36/class-mutation.1.obj
More information about the Squeak-dev