<br><br><div class="gmail_quote">On Wed, Dec 23, 2009 at 12:27 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
2009/12/19 Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; Hi David,<br>
&gt;     Interesting!  To my mind that definition is incorrect.  I would expect<br>
&gt; the sender of a block to be the sender of the enclosing method, in which<br>
&gt; case the definition would arguably be<br>
&gt; BlockClosure methods for accessing<br>
&gt; sender<br>
&gt; ^self home sender<br>
&gt; A block activation&#39;s caller would be it&#39;s sender slot, so within a block you<br>
&gt; might refer to thisContext caller.  But what is arguably a bug in my<br>
&gt; implementation is that within a block activation thisContext sender refers<br>
&gt; to the caller (the sender of value: to the activation&#39;s block) not to the<br>
&gt; sender of the enclosing method.<br>
&gt; I think I may have screwed up badly here and that the correct<br>
&gt; implementations should be<br>
&gt; MethodContext methods for accessing<br>
&gt; caller<br>
&gt; ^closureOrNil<br>
&gt; ifNil: [self error: &#39;this is a method activation and so has no caller&#39;]<br>
&gt; ifNotNil: [sender]<br>
&gt; sender<br>
&gt; ^closureOrNil<br>
&gt; ifNil: [sender]<br>
&gt; ifNotNil: [closureOrNil outerContext sender]<br>
&gt; BlockClosure methods for accessing<br>
&gt; sender<br>
&gt; ^outerContext sender<br>
&gt; and either<br>
&gt; BlockClosure methods for accessing<br>
&gt; caller<br>
&gt; &quot;Since a BlockClosure is by definition not an activation it does not have a<br>
&gt; caller.<br>
&gt;  It has a sender because it is always created within the context of a<br>
&gt; method.&quot;<br>
&gt; ^nil<br>
&gt; or<br>
&gt; BlockClosure methods for accessing<br>
&gt; caller<br>
&gt; ^self error: &#39;this is an inactive block and so has no caller&#39;<br>
&gt;<br>
&gt; I believe the pre-closure definitions are<br>
&gt; ContextPart methods for accessing<br>
&gt; sender<br>
&gt; ^sender<br>
&gt; BlockContext methods for accessing<br>
&gt; caller<br>
&gt; ^sender<br>
&gt; which to my mind is missing<br>
&gt; BlockContext methods for accessing<br>
&gt; sender<br>
&gt; ^home sender<br>
&gt; What do people think the right definitions should be?<br>
<br>
<br>
</div></div>i think the intent of this fix was to match the:<br>
<br>
|x y |<br>
x := thisContext sender.<br>
[ y := thisContext sender ] value.<br>
x == y<br></blockquote><div><br></div><div>NI don&#39;t think so.  Within a block thisContext is not a BlockClosure but a MethodContext (note not a BlockContext).  The fix was for BlockClosure not ContextPart et al.  Again &quot;[] home sender&quot; is the right approach (see below).</div>
<div><br></div><div>(*) That it is a MethodContext is a historical accident.  My closure implementation discards BlockContext.  Some time we should merge ContextPart and MethodContext into a single class Context.</div><div>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Since thisContext variable value depending on scope, where it used.<br>
<br>
The really interesting question to answer is:<br>
<br>
either we threat thisContext as implicitly declared in method&#39;s scope only:<br>
<br>
someMethod<br>
| thisContext |<br>
<br>
[ [ [ [ x := thisContext ] ] ] ]<br>
<br>
or threat as implicitly (re)declared at each level of scoping:<br>
<br>
someMethod<br>
| thisContext |<br>
<br>
[| thisContext | [| thisContext | [| thisContext | [| thisContext | x<br>
:= thisContext ] ] ] ]<br></blockquote><div><br></div><div>Not so interesting :)  It has to be the latter because you have to be able to name the current context.  If you need to mention the former you write &quot;thisContext home&quot;.  And so &quot;aClosureOrContext home sender&quot; will answer the enclosing method activation&#39;s sending context for both blocks and contexts.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
<br>
&gt; On Fri, Dec 18, 2009 at 8:36 PM, &lt;<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; David T. Lewis uploaded a new version of Kernel to project The Trunk:<br>
&gt;&gt; <a href="http://source.squeak.org/trunk/Kernel-dtl.331.mcz" target="_blank">http://source.squeak.org/trunk/Kernel-dtl.331.mcz</a><br>
&gt;&gt;<br>
&gt;&gt; ==================== Summary ====================<br>
&gt;&gt;<br>
&gt;&gt; Name: Kernel-dtl.331<br>
&gt;&gt; Author: dtl<br>
&gt;&gt; Time: 18 December 2009, 11:32:44 am<br>
&gt;&gt; UUID: 20ffffda-86bc-47a7-8eae-cd11b55aa65e<br>
&gt;&gt; Ancestors: Kernel-bs.330<br>
&gt;&gt;<br>
&gt;&gt; Add BlockClosure&gt;&gt;sender required for MessageTally class&gt;&gt;tallySends:<br>
&gt;&gt;<br>
&gt;&gt; Harvested from Pharo (nice 4/14/2009 19:09).<br>
&gt;&gt;<br>
&gt;&gt; =============== Diff against Kernel-bs.330 ===============<br>
&gt;&gt;<br>
&gt;&gt; Item was added:<br>
&gt;&gt; + ----- Method: BlockClosure&gt;&gt;sender (in category &#39;debugger access&#39;) -----<br>
&gt;&gt; + sender<br>
&gt;&gt; +       &quot;Answer the context that sent the message that created the<br>
&gt;&gt; receiver.&quot;<br>
&gt;&gt; +<br>
&gt;&gt; +       ^outerContext sender!<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</font></blockquote></div><br>