<!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: Reflection in Squeak (was: RE: [GOODIE] Delegation and Self like things for Squeak)</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>also embedded.</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: Wednesday, August 22, 2001 7:39 AM</FONT>
<BR><FONT SIZE=2>&gt; To: squeak-dev@lists.squeakfoundation.org</FONT>
<BR><FONT SIZE=2>&gt; Subject: Reflection in Squeak (was: RE: [GOODIE] Delegation and Self</FONT>
<BR><FONT SIZE=2>&gt; like things for Squeak)</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; See embedded comments.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; -----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt; &gt; From: squeak-dev-admin@lists.squeakfoundation.org </FONT>
<BR><FONT SIZE=2>&gt; &gt; [<A HREF="mailto:squeak-dev-admin@lists.squeakfoundation.org">mailto:squeak-dev-admin@lists.squeakfoundation.org</A>] On </FONT>
<BR><FONT SIZE=2>&gt; &gt; Behalf Of Rob Withers</FONT>
<BR><FONT SIZE=2>&gt; &gt; Sent: Wednesday, August 22, 2001 3:40 AM</FONT>
<BR><FONT SIZE=2>&gt; &gt; To: squeak-dev@lists.squeakfoundation.org</FONT>
<BR><FONT SIZE=2>&gt; &gt; Subject: Re: [GOODIE] Delegation and Self like things for Squeak</FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; oops.&nbsp; I wrote:</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; Mirror would implement</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; ------</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; delegate: selector arguments: argArray</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt;</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; ^ self reflectee delegate: selector arguments: argArray</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; -----</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt;</FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; but this doesn't do it.&nbsp; I wanted to execute the delegate </FONT>
<BR><FONT SIZE=2>&gt; &gt; primitive, without implementing #delegate:arguments: in the </FONT>
<BR><FONT SIZE=2>&gt; &gt; Forwarder (that may be chained). Additionally, creating a </FONT>
<BR><FONT SIZE=2>&gt; &gt; mirror will slow it down.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Right...we would need a new delegate primitive that didn't require a</FONT>
<BR><FONT SIZE=2>&gt; message to be installed on the target (see more on this </FONT>
<BR><FONT SIZE=2>&gt; below).&nbsp; But, we</FONT>
<BR><FONT SIZE=2>&gt; do have the delegate bytecodes!&nbsp; You could doctor up a </FONT>
<BR><FONT SIZE=2>&gt; CompiledMethod to</FONT>
<BR><FONT SIZE=2>&gt; do what you need (the compiler won't generate any delegate bytecodes</FONT>
<BR><FONT SIZE=2>&gt; just yet...and I'm not going to make it do so anytime soon)...in fact,</FONT>
<BR><FONT SIZE=2>&gt; the delegate bytecode would be the fastest solution and </FONT>
<BR><FONT SIZE=2>&gt; wouldn't require</FONT>
<BR><FONT SIZE=2>&gt; a new primitive.&nbsp; Also, don't forget about &quot;Mirror on: </FONT>
<BR><FONT SIZE=2>&gt; someObject&quot; which</FONT>
<BR><FONT SIZE=2>&gt; avoids sending the #mirror message (in case you don't want to </FONT>
<BR><FONT SIZE=2>&gt; implement</FONT>
<BR><FONT SIZE=2>&gt; #mirror in your object).&nbsp; If you are chaining these things, then you</FONT>
<BR><FONT SIZE=2>&gt; probably would want to work through a mirror...you can avoid </FONT>
<BR><FONT SIZE=2>&gt; creating a</FONT>
<BR><FONT SIZE=2>&gt; mirror on every message if you hold onto the mirror instead of the</FONT>
<BR><FONT SIZE=2>&gt; target object.</FONT>
</P>

<P><FONT SIZE=2>I'm with you here...An example of doing this is in ProtoBehavior, where you define the accessor and mutator methods for a new slot (compileSlot:...).&nbsp; That's some interesting code!&nbsp; </FONT></P>

<P><FONT SIZE=2>This architecture of chaining managed references, especially now that we ought to use a Mirror, was why I wanted the thinnest possible managed reference.&nbsp; Let's take three spaces (A, B, C) and an object (a) in space A.&nbsp; If we export the reference to space B, then we want to manage the reference with an access manager to Space A.&nbsp; So in space B, the reference to a would be Forwarder to Space A manager on a, configured for access from B, </FONT></P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>Fb(a) := F(B-&gt;a) := F(Ma(B), a).&nbsp; </FONT>
<BR><FONT SIZE=2>If Space B then passes this reference to C, then we would have:&nbsp; </FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>Fc(Fb(a)) := F(C-&gt;F(B-&gt;a)) := F(Mb(C), Fb(a)).&nbsp; It would be nice if we could resolve this to: Fc(a), since they ought to be identical, and since there is no aspect of B filtering access to Fa.&nbsp; Of course there could be, if the access priviledges are degraded for C's use of B references - C may not be able to access A.</FONT></P>

<P><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; Is there a way to invoke a primitive against a different </FONT>
<BR><FONT SIZE=2>&gt; &gt; receiver, in Squeak?&nbsp; For example, In a doIt, invoke </FONT>
<BR><FONT SIZE=2>&gt; &gt; &lt;primitive: 1&gt; and supply the 2 numbers - one the receiver </FONT>
<BR><FONT SIZE=2>&gt; &gt; and the other the argument.</FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; - Rob</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; No...not unless you write a new primitive...which is what </FONT>
<BR><FONT SIZE=2>&gt; I've done for</FONT>
<BR><FONT SIZE=2>&gt; a few things that are required by Mirror to avoid sending a message to</FONT>
<BR><FONT SIZE=2>&gt; the reflectee.&nbsp; In fact, there are a lot of things that you might want</FONT>
<BR><FONT SIZE=2>&gt; to invoke in this way.&nbsp; I'm starting to believe that a lot of the very</FONT>
<BR><FONT SIZE=2>&gt; basic primitives should be re-implemented such that they do </FONT>
<BR><FONT SIZE=2>&gt; not require</FONT>
<BR><FONT SIZE=2>&gt; that the method be installed the subject.&nbsp; However, this allows one to</FONT>
<BR><FONT SIZE=2>&gt; break encapsulation...but if we could find some way for an object to</FONT>
<BR><FONT SIZE=2>&gt; restrict (or disable entirely) who is allowed to use reflection</FONT>
<BR><FONT SIZE=2>&gt; primitives against it, I think it just may be the way to go.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
</P>

<P><FONT SIZE=2>Right...Primitives shouldn't push the receiver, but rather that would be an explicit argument to the primitive method context.&nbsp; Nice.</FONT></P>

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

<P><FONT SIZE=2>&gt; There are some basic operations in Squeak that require the ProtoObject</FONT>
<BR><FONT SIZE=2>&gt; protocol, those operations could be re-written such that if </FONT>
<BR><FONT SIZE=2>&gt; the message</FONT>
<BR><FONT SIZE=2>&gt; they are sending isn't implemented, then they fall back on a </FONT>
<BR><FONT SIZE=2>&gt; reflection</FONT>
<BR><FONT SIZE=2>&gt; primitive (like #== for example).&nbsp; Certain operations that really need</FONT>
<BR><FONT SIZE=2>&gt; the method natively implemented would not send the message to </FONT>
<BR><FONT SIZE=2>&gt; the object</FONT>
<BR><FONT SIZE=2>&gt; at all, and use the reflection primitive instead (like #nextObject for</FONT>
<BR><FONT SIZE=2>&gt; example...that one absolutely has to return an answer appropriate for</FONT>
<BR><FONT SIZE=2>&gt; itself, or infinite looping can happen (or inaccurate results from a</FONT>
<BR><FONT SIZE=2>&gt; references search)).</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; - Stephen</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
</P>

</BODY>
</HTML>