<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi all,</p>
<p><br>
</p>
<p>recently, Patrick has raised an interesting question about doIt expression in debuggers/context-relative environments. Here is a concrete example:</p>
<p><br>
</p>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<p>Foo subclass Bar subclass Baz</p>
<p>Foo>><span style="font-size: 12pt;">something</span></p>
<p></p>
<div><span style="white-space:pre"></span>^ #foo</div>
<p></p>
<p></p>
<div>Bar>>something</div>
<p></p>
<p></p>
<div><span><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px; white-space: pre;"></span>^ {super something. #bar}</span></div>
<p></p>
<p></p>
<div><span>Baz>></span><span style="font-size: 12pt;">something</span></div>
<p></p>
<p></p>
<div><span>
<div><span style="white-space:pre"></span>^ {super something. #baz}</div>
</span></div>
<p></p>
</blockquote>
<p></p>
<div><span>
<div><br>
</div>
<div>"Baz new something" answers "#((foo bar) baz)" of course.</div>
<div>Now debug the send and step into <span>Baz(Bar)>>something so that the next send "super something" will answer "#foo".</span></div>
<div><span>However, if you select the expression in the contents pane and print-it (you can also do the same in the ContextVariablesInspector on the right), you will get "#(foo bar)" instead.</span></div>
<div><span><br>
</span></div>
<div><span>The reason is that the context-relative doIt will be compiled against the class of the context receiver - which is Baz - instead of the method class of the context. See Compiler >> #<span>classForReceiver:context: and senders.</span></span></div>
<div><span><span>Here is a very simple patch that could solve this problem:</span></span></div>
<div><span><span><br>
</span></span></div>
</span></div>
<p></p>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<p></p>
<div><span>
<div><span><span>
<div>Compiler>>classForReceiver: receiver context: contextOrNil</div>
</span></span></div>
</span></div>
<p></p>
<p></p>
<div><span>
<div><span><span>
<div>-   <span style="white-space:pre"> </span>^thisContext objectClass: (contextOrNil ifNil: [receiver] ifNotNil: [contextOrNil receiver])</div>
</span></span></div>
</span></div>
<p></p>
<p></p>
<div><span>
<div><span><span>
<div>+   <span style="white-space:pre"> </span>contextOrNil ifNil: [^ thisContext objectClass: receiver].</div>
</span></span></div>
</span></div>
<p></p>
<p></p>
<div><span>
<div><span><span>
<div>+   <span style="white-space:pre"> </span>^ contextOrNil method methodClass</div>
</span></span></div>
</span></div>
<p></p>
</blockquote>
<p></p>
<div><span>
<div><span><span><br>
</span></span></div>
<div><span><span>So I would like to discuss this behavior: In my opinion, it is definitively confusing that a print-it in a debugger pane behaves differently than actually sending the message. We cannot always reach exactly the same result and behavior, but
 IMHO we should always strive for it.</span></span></div>
<div><span><span>On the other hand, especially when working in the ContextVariablesInspector instead of the contents pane, you might indeed expect that your doits are compiled against the actual receiver class. Another consequence of the above patch would be that
 instance variables defined in subclasses of the context methodClass become unavailable for doits. However, you can still use the left receiver inspector for reaching these variables.</span></span></div>
<div><span><span><br>
</span></span></div>
<div><span><span>What do you think? :-) Would it be okay to use the lookup class of the selected context's method for context-relative doits or do you have any objections against it? Or do you think it is necessary to distinguish between the ContextVariablesInspector
 and the contents pane (while I think this would increase the perceived complexity, too ...)?</span></span></div>
<div><span><span><br>
</span></span></div>
<div><span><span>Looking forward to your opinions - if you do not have any objections, I will send my patch to the inbox soon. :-)</span></span></div>
<div><span><span><br>
</span></span></div>
<div><span><span>Best,</span></span></div>
<div><span><span>Christoph</span></span></div>
<div><span><span><br>
</span></span></div>
<div><span><span>PS1: Note that we would also need to patch Shout styling accordingly. However, this shouldn't be a huge problem.</span></span></div>
<div><span><span>PS2: When talking about the "execution environment" of doit expressions (not to be confused with the Environment class for bindings!), we might also consider other aspects. Should we maybe also apply process-faithful debugging to them? Until
 today, stepping vs. doing-it an expression that refers to "Processor activeProcess" in a debugger yields different results ...</span></span></div>
</span></div>
<p></p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
</body>
</html>