<!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>> -----Original Message-----</FONT>
<BR><FONT SIZE=2>> From: Stephen Pair [<A HREF="mailto:spair@advantive.com">mailto:spair@advantive.com</A>]</FONT>
<BR><FONT SIZE=2>> Sent: Wednesday, August 22, 2001 7:39 AM</FONT>
<BR><FONT SIZE=2>> To: squeak-dev@lists.squeakfoundation.org</FONT>
<BR><FONT SIZE=2>> Subject: Reflection in Squeak (was: RE: [GOODIE] Delegation and Self</FONT>
<BR><FONT SIZE=2>> like things for Squeak)</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> See embedded comments.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> > -----Original Message-----</FONT>
<BR><FONT SIZE=2>> > From: squeak-dev-admin@lists.squeakfoundation.org </FONT>
<BR><FONT SIZE=2>> > [<A HREF="mailto:squeak-dev-admin@lists.squeakfoundation.org">mailto:squeak-dev-admin@lists.squeakfoundation.org</A>] On </FONT>
<BR><FONT SIZE=2>> > Behalf Of Rob Withers</FONT>
<BR><FONT SIZE=2>> > Sent: Wednesday, August 22, 2001 3:40 AM</FONT>
<BR><FONT SIZE=2>> > To: squeak-dev@lists.squeakfoundation.org</FONT>
<BR><FONT SIZE=2>> > Subject: Re: [GOODIE] Delegation and Self like things for Squeak</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > oops. I wrote:</FONT>
<BR><FONT SIZE=2>> > > Mirror would implement</FONT>
<BR><FONT SIZE=2>> > > ------</FONT>
<BR><FONT SIZE=2>> > > delegate: selector arguments: argArray</FONT>
<BR><FONT SIZE=2>> > ></FONT>
<BR><FONT SIZE=2>> > > ^ self reflectee delegate: selector arguments: argArray</FONT>
<BR><FONT SIZE=2>> > > -----</FONT>
<BR><FONT SIZE=2>> > ></FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > but this doesn't do it. I wanted to execute the delegate </FONT>
<BR><FONT SIZE=2>> > primitive, without implementing #delegate:arguments: in the </FONT>
<BR><FONT SIZE=2>> > Forwarder (that may be chained). Additionally, creating a </FONT>
<BR><FONT SIZE=2>> > mirror will slow it down.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Right...we would need a new delegate primitive that didn't require a</FONT>
<BR><FONT SIZE=2>> message to be installed on the target (see more on this </FONT>
<BR><FONT SIZE=2>> below). But, we</FONT>
<BR><FONT SIZE=2>> do have the delegate bytecodes! You could doctor up a </FONT>
<BR><FONT SIZE=2>> CompiledMethod to</FONT>
<BR><FONT SIZE=2>> do what you need (the compiler won't generate any delegate bytecodes</FONT>
<BR><FONT SIZE=2>> just yet...and I'm not going to make it do so anytime soon)...in fact,</FONT>
<BR><FONT SIZE=2>> the delegate bytecode would be the fastest solution and </FONT>
<BR><FONT SIZE=2>> wouldn't require</FONT>
<BR><FONT SIZE=2>> a new primitive. Also, don't forget about "Mirror on: </FONT>
<BR><FONT SIZE=2>> someObject" which</FONT>
<BR><FONT SIZE=2>> avoids sending the #mirror message (in case you don't want to </FONT>
<BR><FONT SIZE=2>> implement</FONT>
<BR><FONT SIZE=2>> #mirror in your object). If you are chaining these things, then you</FONT>
<BR><FONT SIZE=2>> probably would want to work through a mirror...you can avoid </FONT>
<BR><FONT SIZE=2>> creating a</FONT>
<BR><FONT SIZE=2>> mirror on every message if you hold onto the mirror instead of the</FONT>
<BR><FONT SIZE=2>> 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:...). That's some interesting code! </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. Let's take three spaces (A, B, C) and an object (a) in space A. If we export the reference to space B, then we want to manage the reference with an access manager to Space A. 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> <FONT SIZE=2>Fb(a) := F(B->a) := F(Ma(B), a). </FONT>
<BR><FONT SIZE=2>If Space B then passes this reference to C, then we would have: </FONT>
<BR> <FONT SIZE=2>Fc(Fb(a)) := F(C->F(B->a)) := F(Mb(C), Fb(a)). 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. 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>> </FONT>
<BR><FONT SIZE=2>> > Is there a way to invoke a primitive against a different </FONT>
<BR><FONT SIZE=2>> > receiver, in Squeak? For example, In a doIt, invoke </FONT>
<BR><FONT SIZE=2>> > <primitive: 1> and supply the 2 numbers - one the receiver </FONT>
<BR><FONT SIZE=2>> > and the other the argument.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > - Rob</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> No...not unless you write a new primitive...which is what </FONT>
<BR><FONT SIZE=2>> I've done for</FONT>
<BR><FONT SIZE=2>> a few things that are required by Mirror to avoid sending a message to</FONT>
<BR><FONT SIZE=2>> the reflectee. In fact, there are a lot of things that you might want</FONT>
<BR><FONT SIZE=2>> to invoke in this way. I'm starting to believe that a lot of the very</FONT>
<BR><FONT SIZE=2>> basic primitives should be re-implemented such that they do </FONT>
<BR><FONT SIZE=2>> not require</FONT>
<BR><FONT SIZE=2>> that the method be installed the subject. However, this allows one to</FONT>
<BR><FONT SIZE=2>> break encapsulation...but if we could find some way for an object to</FONT>
<BR><FONT SIZE=2>> restrict (or disable entirely) who is allowed to use reflection</FONT>
<BR><FONT SIZE=2>> primitives against it, I think it just may be the way to go.</FONT>
<BR><FONT SIZE=2>> </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. Nice.</FONT></P>
<P><FONT SIZE=2>cheers,</FONT>
<BR><FONT SIZE=2>Rob</FONT>
</P>
<P><FONT SIZE=2>> There are some basic operations in Squeak that require the ProtoObject</FONT>
<BR><FONT SIZE=2>> protocol, those operations could be re-written such that if </FONT>
<BR><FONT SIZE=2>> the message</FONT>
<BR><FONT SIZE=2>> they are sending isn't implemented, then they fall back on a </FONT>
<BR><FONT SIZE=2>> reflection</FONT>
<BR><FONT SIZE=2>> primitive (like #== for example). Certain operations that really need</FONT>
<BR><FONT SIZE=2>> the method natively implemented would not send the message to </FONT>
<BR><FONT SIZE=2>> the object</FONT>
<BR><FONT SIZE=2>> at all, and use the reflection primitive instead (like #nextObject for</FONT>
<BR><FONT SIZE=2>> example...that one absolutely has to return an answer appropriate for</FONT>
<BR><FONT SIZE=2>> itself, or infinite looping can happen (or inaccurate results from a</FONT>
<BR><FONT SIZE=2>> references search)).</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> - Stephen</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
</P>
</BODY>
</HTML>