<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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><span style="font-size: 12pt;">Hi Christian, hi all,</span><br>
</p>
<div dir="ltr">
<div id="x_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;">
<p><br>
</p>
<p>I already implemented the simulation of objects as methods in <span>Kernel-ct.1339 (Inbox). It has been working fine for me since February - we only need to get things like this merged sooner to prevent everyone from reinventing the wheel. :-)</span></p>
<p><span><br>
</span></p>
<p><span>Best,</span></p>
<p><span>Christoph</span></p>
<div id="x_Signature">
<div id="x_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="x_divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div>
<div class="x__rp_T4" id="x_Item.MessagePartBody">
<div class="x__rp_U4 x_ms-font-weight-regular x_ms-font-color-neutralDark x_rpHighlightAllClass x_rpHighlightBodyClass" id="x_Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="x_divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="x_Signature">
<div style="margin:0px"><font style="font-family:Calibri,Arial,Helvetica,sans-serif,serif,EmojiFont">
<div><font size="3" color="black"><span style="font-size:12pt"><a href="http://www.hpi.de/" target="_blank" rel="noopener noreferrer" id="LPNoLP"><font size="2"><span id="LPlnk909538"><font color="#757B80"></font></span></font></a></span></font></div>
</font></div>
</div>
</font></div>
</div>
</div>
</div>
</div>
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Eliot Miranda <eliot.miranda@gmail.com><br>
<b>Gesendet:</b> Mittwoch, 21. Oktober 2020 16:59:06<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] Debugger / Simulator cannot simulate (some) objects as methods</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt">
<div class="PlainText">Hi,<br>
<br>
> On Oct 21, 2020, at 6:09 AM, cmfcmf <cmfcmf.flach@gmail.com> wrote:<br>
> <br>
> Hi,<br>
> <br>
> when using simple objects as methods, the simulator (and therefore the<br>
> debugger also) raises an error if the object used as method does not<br>
> implement certain methods from CompiledMethod (e.g., numArgs). If such code<br>
> is debugged, the debugger opens a never-ending stream of error windows.<br>
> <br>
> I am under the (possibly wrong) assumption that objects as methods should<br>
> _not_ need to implement the complete CompiledMethod protocol to be<br>
> compatible with simulation and debugging.<br>
<br>
Since the only gap that needs filling is from the retrieval of the object from the method dictionary to the send of run:asMethod:withAruuments: (or whatever the actual selector is) let me suggest that you create a wrapper class whose instances hold on to an
 object to be run as a method and the selector and argument count and respond to the required CompiledCode protocol.  Then modify the simulator at the point where it gets the result of the message lookup from the dictionary and wraps the result in one of these
 if it is neither CompiledCode (isCompiledCode) not nil. We don’t want to litter the simulation code with checks and the wrapper approach has the best chance.<br>
<br>
Of course another test will be needed before a new contest is created, and maybe one test at the top of the tryPrimitive: method.<br>
<br>
> <br>
> I have attached a failing test called Context2Test that uses the simulator<br>
> to simulate a call of an object as method. You can also see the<br>
> "never-ending stream of error windows" by placing a "self halt" at the top<br>
> of the test and then stepping through the first assertion using the "over"<br>
> button. WARNING: Might make your image unusable.<br>
> <br>
> The root cause is the Context >> #send:to:with:lookupIn: method which<br>
> assumes that all methods are CompiledMethods. I have attached a simple fix<br>
> that works great for me – let me know what you think about it.<br>
> <br>
> Best<br>
> Christian<br>
> <br>
> Context2Test.st <<a href="http://forum.world.st/file/t372201/Context2Test.st">http://forum.world.st/file/t372201/Context2Test.st</a>> 
<br>
> Context-sendtowithlookupIn.st<br>
> <<a href="http://forum.world.st/file/t372201/Context-sendtowithlookupIn.st">http://forum.world.st/file/t372201/Context-sendtowithlookupIn.st</a>> 
<br>
> <br>
> <br>
> <br>
> --<br>
> Sent from: <a href="http://forum.world.st/Squeak-Dev-f45488.html">http://forum.world.st/Squeak-Dev-f45488.html</a><br>
> <br>
<br>
</div>
</span></font></div>
</body>
</html>