<br><br><div><span class="gmail_quote">On 9/28/07, <b class="gmail_sendername">Alejandro Martínez</b> &lt;<a href="mailto:alemartinez2112@gmail.com">alemartinez2112@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I was thinking about implementing a Proxy but instead the usual way which I believe is subclassing from ProtoObject, I subclassed from Object a ProxyObject with an iVar called encapsulatedObject, and then write<br><br>ProxyObject &gt;&gt;doesNotUnderstand: aMessage 
<br>&nbsp;&nbsp;&nbsp; ^aMessage sendTo: self encapsulatedObject<br><br>Then for every message I need to intercept, I write:<br><br>ProxyObject &gt;&gt;at: index put: value <br>&nbsp;&nbsp;&nbsp; ^self doesNotUnderstand: (Message selector: #at:put: <br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arguments: (Array with: index with: value)).<br><br>ProxyObject&gt;&gt;asString<br>&nbsp;&nbsp;&nbsp; ^self doesNotUnderstand: (Message selector: #asString).<br><br>ProxyObject&gt;&gt;name
<br>&nbsp;&nbsp;&nbsp; ^self doesNotUnderstand: (Message selector: #name).<br><br>....<br><br>ok... you get the idea.<br>But I was reading a paper called &quot;Evaluating Message Passing Control Techniques in Smalltalk&quot; from Stéphane Ducasse, and supposed my idea qualified as &quot;minimal object&quot;. He wrote:
<br><br>&quot;The right technique to create a minimal object is the following: <br>(1) creation of a subclass of Object,<br>(2) assignment of the superclass link to nil and<br>(3) definition of the minimal behavior by copying the needed methods from Object&quot;
<br><br>But I&#39;ve implemented it without (2) and doing some message replication mentioned above (currently I have no more than 15 of those kind of messages) it would, at first, bypass the problem described in the &quot;Problems&quot; section:
<br><br>&quot;This leads to the problem of the interpretation by the minimal object of messages that were initially destined for the controlled object&quot;<br><br>Hope I&#39;ve understood the right way. However, something still smells bad to me... and that&#39;s why I&#39;m writing to the list for some advice or suggestion. The only real problem I&#39;ve experimented is when the replication of #ifNil: nilBlock takes place, this doesn&#39;t seem to work:
<br><br>ProxyObject&gt;&gt;ifNil: nilBlock<br>&nbsp;&nbsp;&nbsp; ^self doesNotUnderstand: (Message selector: #ifNil: argument: nilBlock).<br><br>(my guess here is there&#39;s some optimization thing walking around)<br><br>So, for those cool guys here, can you tell me if there is a possible drawback or unwanted behavior I&#39;m not seeing? If true in which case would happen? Is this a valid way of implementing a Proxy or there&#39;s something I&#39;ve missing? (I suspect a performance penalty, but I&#39;m not sure about this)
</blockquote><div><br>Hi <span class="gmail_quote"><span class="gmail_sendername">Alejandro </span></span></div><br></div>I&#39;ve got a pre-packaged, working version of a proxy. I&#39;ve spent a long time trying to get it to work without crashing inspectors and debuggers, and it&#39;s still not perfect. Give it a try if you want:
<br><br><a href="http://www.squeaksource.com/DPON/MessageCapture-mvdg.9.mcz">http://www.squeaksource.com/DPON/MessageCapture-mvdg.9.mcz</a><br><br>Gulik.<br clear="all"><br>-- <br><a href="http://people.squeakfoundation.org/person/mikevdg">
http://people.squeakfoundation.org/person/mikevdg</a><br><a href="http://gulik.pbwiki.com/">http://gulik.pbwiki.com/</a>