[GOODIE] Delegation and Self like things for Squeak

Stephen Pair spair at advantive.com
Tue Aug 21 21:49:14 UTC 2001


Rob,

I've compiled a Linux VM with RedHat 6.2, it seems to check out OK.  The
zip file now just contains an image and changes file.  So, try getting
that and the linux VM and see if you have better luck.  I've release
Rev.4 of the Delegation change set which fixes a couple of things and
cleans up a couple of other things.

>I does start to seem like just an extended Proxy, with the ability to
install methods.  This is very nice, but it may not be the thing I think
I need.  Having instance methods, or rather reference-scoped methods, is
half of the solution.  The other bit is a truly stateless, first-class
reference, that maintains identity, but allows for method override and
lookup notification.
>
>I believe it would depend on how we bring Forwarder/ManagedObjects
support using this mechanism.  The forwardee would be a parental slot,
that would have it's protocol delegated too.  How would we do pushSelf
substitution in this scheme?  I imagine that the receiverSelf for the
forwardee would be the forwarder prototype.
>
>I understand about the storage overhead (receiverMap) - that sucks.  We
need a first class reference object, that the VM knows how to
manipulate.  
>
>For my desire to have managed objects (managing message sending), this
provides a mechanism to override methods at the instance level in the
proxy prototype.  I would have to compile/install all methods I want to
intercept, with the correct intercept code.  So for my needs, I would
rather have a way to either:
>        1 - have a message lookup notification, with the ability to
either cancel further lookup, or choose not to resend
>        2 - have the ability to install custom lookup methods for an
instance, and have the VM check and activate custom lookup when a send
occurs.
>Another alternative is a notification whenever lookup is changing it's
scope to a superclass or parent, as the case may be.
>- Rob

Rob...Try this:

- create a new prototype
- set it's superclass to ProtoObject (necessary to peacefully exist in
squeak)
- remove all slots except one, which is *not* a parent slot (let's call
it "target")
- remove all methods
- add the following method:

-------
doesNotUnderstand: aMessage
	"Do your stuff here"

	^target delegate: aMessage selector arguments: aMessage
arguments
-------

Does this not give you the power to intercept all messages and do what
you need to do?  In effect, this is an object with a completely
customized message response scheme (with the exception of the
ProtoObject methods...which could also be eliminated if a few tweeks to
the base Squeak stuff). 

The reason we don't have target as a parent is because the VM would
attempt to go ahead and delegate the message before you had a chance to
intercept it.

- Stephen






More information about the Squeak-dev mailing list