Overriding #class
stephane ducasse
stephane.ducasse at free.fr
Wed Nov 14 20:05:07 UTC 2007
Hi martin
this is fun. I did that in VW and it worked like you mention (see my
JOOP Message passing control in Smalltalk).
I defined class to return the superclass (if I remember correctly)
and meta object to return the class.
Then I could get instance based control as in Coda. Now in Squeak the
ideas developed in the paper could
not be implemented because class was not redefinable :(
Stef
On 13 nov. 07, at 11:28, Martin Beck wrote:
> Hello,
>
> we have a little problem while implementing a CodA meta-object
> protocol. The facility we try to implement now (or first :) ) is
> that every instance should have the possibility to add behaviour
> (i.e. methods) to it, but not to the class. Our first approach,
> which was also advised in Jeff McAffer's papers, was to insert
> 'anonymous' classes, which implement these methods and change the
> objects class to that new foo-class.
>
> However, to retain normal behaviour, we want to override the #class
> method to return the real class of the object, not the inserted
> one. The CodA metastructure will be accessed through a #meta message.
>
> As you might have expected, our problem is now, that the compiler
> optimizes the #class send and therefore the code only works in the
> debugger. Our question is now, whether there is an easy and
> shareable (Monticello, etc.) way to disable these optimizations and
> whether this idea could work with the current VM implementation? If
> the VM doesn't use the #class method to bind messages to an object
> to the methods of its class, we think that it could be possible,
> but if this lookup is not built into the VM but rather into the ST
> system, we have to go another way...
>
> Any ideas? Maybe replacing the object which shall be extended by a
> method with a proxy, catch every message and do the lookup ourselves?
>
> Regards,
> Martin
>
>
More information about the Squeak-dev
mailing list
|