<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [GOODIE] Delegation and Self like things for Squeak</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Hi Stephen,</FONT>
</P>

<P><FONT SIZE=2>I will attempt the full VM build and image preparation this evening and let you know how my Linux machine likes it.&nbsp; As you know, I had difficulty with the Forwarder changeset under Linux.&nbsp; I am wondering if it may have been due to my not running the image prep code you list here.</FONT></P>

<P><FONT SIZE=2>It strikes me that this may be an alternative to your proposal for differentiating multiple versions of the same message.&nbsp; If we proxy an object reference, with a delegate, then we can pick up any overriding implementations of a method for it's class, within that Module.&nbsp; Instead on overriding a superclass' implementation, we are overriding a class implementation in an inner, more generic module, with an implementation in a more specific module implementation.&nbsp; In this way, don't extensions of classes between modules look like Self-style inheritance?</FONT></P>

<P><FONT SIZE=2>I will post another more specific to my Module questions...</FONT>
</P>

<P><FONT SIZE=2>cheers,</FONT>
<BR><FONT SIZE=2>Rob</FONT>
</P>

<P><FONT SIZE=2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt; From: Stephen Pair [<A HREF="mailto:spair@advantive.com">mailto:spair@advantive.com</A>]</FONT>
<BR><FONT SIZE=2>&gt; Sent: Friday, August 17, 2001 11:48 PM</FONT>
<BR><FONT SIZE=2>&gt; To: squeak-dev@lists.squeakfoundation.org</FONT>
<BR><FONT SIZE=2>&gt; Subject: [GOODIE] Delegation and Self like things for Squeak</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; The following is copied from the web page: <A HREF="http://spair.swiki.net/21" TARGET="_blank">http://spair.swiki.net/21</A></FONT>
<BR><FONT SIZE=2>&gt; (which also contains screenshot).</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; -------------</FONT>
<BR><FONT SIZE=2>&gt; === Overview</FONT>
<BR><FONT SIZE=2>&gt; This change set adds delegation capabilities to the Squeak VM. It also</FONT>
<BR><FONT SIZE=2>&gt; extends some previous work on prototypes by Hans Martin Mosner to</FONT>
<BR><FONT SIZE=2>&gt; implement a Self-like (<A HREF="http://self.sunlabs.com" TARGET="_blank">http://self.sunlabs.com</A>) system within Squeak.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Delegation is the act of forwarding a message to another object, but</FONT>
<BR><FONT SIZE=2>&gt; maintaining the original receiver such that sends to self in the new</FONT>
<BR><FONT SIZE=2>&gt; method context will be directed back to the delegating object.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; === Screenshot</FONT>
<BR><FONT SIZE=2>&gt; The following screenshot shows ProtoInspectors open on a family</FONT>
<BR><FONT SIZE=2>&gt; (literally) of objects. They are arranged according to their </FONT>
<BR><FONT SIZE=2>&gt; inheritance</FONT>
<BR><FONT SIZE=2>&gt; hierarchy. Slots with an asterisk denote parent slots (their </FONT>
<BR><FONT SIZE=2>&gt; behavior is</FONT>
<BR><FONT SIZE=2>&gt; inherited by the child). The image doesn't show it, but you </FONT>
<BR><FONT SIZE=2>&gt; may have any</FONT>
<BR><FONT SIZE=2>&gt; number of parent slots.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt;&nbsp; &lt;&lt;see web page: <A HREF="http://spair.swiki.net/21" TARGET="_blank">http://spair.swiki.net/21</A>&gt;&gt;</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; === Implementation Details</FONT>
<BR><FONT SIZE=2>&gt; Two new bytecodes are added to the VM:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; singleExtendedDelegateBytecode </FONT>
<BR><FONT SIZE=2>&gt; doubleExtendedDelegateBytecode </FONT>
<BR><FONT SIZE=2>&gt; (but the compiler has not yet been modified to generate these </FONT>
<BR><FONT SIZE=2>&gt; bytecodes)</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Several new primtives are added to support delegation and reflection</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; primitiveDelegate - added to Object as #delegate:, #delegate:with:,</FONT>
<BR><FONT SIZE=2>&gt; ...etc </FONT>
<BR><FONT SIZE=2>&gt; primitiveDelegateArgs - added to Object as #delegate:withArguments: </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; The following primitives allow a Mirror to reflect on objects without</FONT>
<BR><FONT SIZE=2>&gt; needing to send messages to the reflectee (this allows mirror to</FONT>
<BR><FONT SIZE=2>&gt; manipulate objects that may have a very lightweight protocol):</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; primitiveGetSlots </FONT>
<BR><FONT SIZE=2>&gt; primitiveSetSlots </FONT>
<BR><FONT SIZE=2>&gt; primitiveGetProtoBehavior </FONT>
<BR><FONT SIZE=2>&gt; primitiveSetProtoBehavior </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; The message lookup algorithm is also modified to search the </FONT>
<BR><FONT SIZE=2>&gt; parent slots</FONT>
<BR><FONT SIZE=2>&gt; of objects whos class is an instance of ProtoBehavior. This allows for</FONT>
<BR><FONT SIZE=2>&gt; instance based, multiple inheritance.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Bytecodes accessing the internal structure of an object</FONT>
<BR><FONT SIZE=2>&gt; (pushReceiverVariable and kin) are modified such that the look to the</FONT>
<BR><FONT SIZE=2>&gt; &quot;receiverStorage&quot; object in the active context. In normal messages</FONT>
<BR><FONT SIZE=2>&gt; receiverStorage is identical to receiver, but in delegated </FONT>
<BR><FONT SIZE=2>&gt; methods, they</FONT>
<BR><FONT SIZE=2>&gt; will be different.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; You may create object that inherit behavior from normal Smalltalk</FONT>
<BR><FONT SIZE=2>&gt; instances (direct instance variable manipulation will affect </FONT>
<BR><FONT SIZE=2>&gt; the parent</FONT>
<BR><FONT SIZE=2>&gt; object, not the child's slots).</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Hans Martin Mosner's HmmProtoObject class has been dropped in favor of</FONT>
<BR><FONT SIZE=2>&gt; the Mirror class and a reflection based approach to </FONT>
<BR><FONT SIZE=2>&gt; meta-programming in</FONT>
<BR><FONT SIZE=2>&gt; the spirit of Self. To add or remove slots or methods, you must use a</FONT>
<BR><FONT SIZE=2>&gt; mirror (unless you add methods to your instance). The </FONT>
<BR><FONT SIZE=2>&gt; ProtoInpector now</FONT>
<BR><FONT SIZE=2>&gt; uses a Mirror to manipulate an object. This allows objects to be</FONT>
<BR><FONT SIZE=2>&gt; inspected and manipulated even if they have no behavior.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; The VM has also been enhanced such that a recursive </FONT>
<BR><FONT SIZE=2>&gt; #doesNotUnderstand:</FONT>
<BR><FONT SIZE=2>&gt; will not crash the image, but lookup the #doesNotUnderstand: on Object</FONT>
<BR><FONT SIZE=2>&gt; (and you will get a #doesNotUnderstand: on a #doesNotUnderstand:</FONT>
<BR><FONT SIZE=2>&gt; message). This was done because the likelyhood of </FONT>
<BR><FONT SIZE=2>&gt; accidentally creating</FONT>
<BR><FONT SIZE=2>&gt; objects that don't understand #doesNotUnderstand: has increased</FONT>
<BR><FONT SIZE=2>&gt; dramatically with the introduction of ProtoBehavior.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; There should now be enough support in the VM to implement a pretty</FONT>
<BR><FONT SIZE=2>&gt; robust implementation of Self within Squeak. It would be </FONT>
<BR><FONT SIZE=2>&gt; really cool to</FONT>
<BR><FONT SIZE=2>&gt; see the Self tools for manipulating objects recreated in Squeak.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; === Issues</FONT>
<BR><FONT SIZE=2>&gt; The compiler has not been modified in any way, shape or form to</FONT>
<BR><FONT SIZE=2>&gt; implement anything like the Self syntax. This means that doing certain</FONT>
<BR><FONT SIZE=2>&gt; things can be awkward. Additionally, this means that you must use</FONT>
<BR><FONT SIZE=2>&gt; #delegate: or one of it's variants in order to accomplish what Self</FONT>
<BR><FONT SIZE=2>&gt; calls a &quot;resend.&quot; Also, only a directed resend is possible.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; There is no way to store instance based source code, therefore, all</FONT>
<BR><FONT SIZE=2>&gt; methods appear in their de-compiled form. This is a pain.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; === Downloading</FONT>
<BR><FONT SIZE=2>&gt; There are three things that you can download:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; 1. A bundle that includes a demo image, changes file, and a Win32 VM</FONT>
<BR><FONT SIZE=2>&gt; 2. Just the change set (you will need to compile your own VM </FONT>
<BR><FONT SIZE=2>&gt; and follow</FONT>
<BR><FONT SIZE=2>&gt; the procedure below to get an existing image prepared to run on it)</FONT>
<BR><FONT SIZE=2>&gt; 3. Just the win32 VM (note, trying to run a base Squeak image </FONT>
<BR><FONT SIZE=2>&gt; on this VM</FONT>
<BR><FONT SIZE=2>&gt; won't get you very far very fast)</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; If you are going to compile you own VM, you will need to load </FONT>
<BR><FONT SIZE=2>&gt; the change</FONT>
<BR><FONT SIZE=2>&gt; set, and then execute the following code in a workspace to prepare the</FONT>
<BR><FONT SIZE=2>&gt; existing method contexts in your image:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; MethodContext allInstances do: </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; [ :ea | ea instVarNamed: #receiverMap put: ea receiver ].</FONT>
<BR><FONT SIZE=2>&gt; Smalltalk snapshot: true andQuit: true.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Then, you should have an image that will work on your new VM with</FONT>
<BR><FONT SIZE=2>&gt; support for delegation.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Enjoy!</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
</P>

</BODY>
</HTML>