<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hi Christian,<div dir="ltr"><br><blockquote type="cite">On Oct 23, 2020, at 9:32 AM, Christian Flach <cmfcmf.flach@gmail.com> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">Hi, <div><br></div><div>Christoph – great to hear that you also ran into this issue and have already proposed a very similar fix (your fix even being a bit more 'correct' than mine, since it avoids sending the class message)!</div><div><br></div><div>Eliot – thank you for your insights. If I'm not mistaken, your proposed solution would add additional restrictions to objects as methods (OAMs) during simulation and debugging. This is because OAMs are more flexible than CompiledMethods: For example, unlike a CompiledMethod, an OAM does not have a fixed number of arguments it can respond to. Take a look at the following OAM that responds 

to a message send

with the number of arguments sent:</div><div><br></div><div>run: selector with: arguments in: aReceiver</div><div>    ^ arguments size</div><div><br></div><div>The proposed wrapper class would not be able to 

adequately

respond to the numArgs message for this OAM.</div></div></div></blockquote><div><br></div>Well a wrapper could have as much stats as one wanted, but ...<div><br><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div><br></div><div>I personally also don't feel like adjusting a single method inside the simulator by adding a check for OAMs would "litter the simulation code".</div></div></div></blockquote><div><br></div>Cool, glad to hear only one method is changed.  Can we not move this to trunk?</div><div><br><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div><br></div><div>Best,</div><div>Christian</div><div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Do., 22. Okt. 2020 um 19:28 Uhr schrieb Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de">Christoph.Thiede@student.hpi.uni-potsdam.de</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div id="gmail-m_6020608377945987580divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);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="gmail-m_6020608377945987580x_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="gmail-m_6020608377945987580x_Signature">
<div id="gmail-m_6020608377945987580x_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">
<div>
<div id="gmail-m_6020608377945987580x_Item.MessagePartBody">
<div id="gmail-m_6020608377945987580x_Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="gmail-m_6020608377945987580x_divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="gmail-m_6020608377945987580x_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/" rel="noopener noreferrer" id="gmail-m_6020608377945987580LPNoLP" target="_blank"><font size="2"><span id="gmail-m_6020608377945987580LPlnk909538"><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 style="display:inline-block;width:98%">
<div id="gmail-m_6020608377945987580x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org" target="_blank">squeak-dev-bounces@lists.squeakfoundation.org</a>> im Auftrag von Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>><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>Hi,<br>
<br>
> On Oct 21, 2020, at 6:09 AM, cmfcmf <<a href="mailto:cmfcmf.flach@gmail.com" target="_blank">cmfcmf.flach@gmail.com</a>> 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" target="_blank">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" target="_blank">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" target="_blank">http://forum.world.st/Squeak-Dev-f45488.html</a><br>
> <br>
<br>
</div>
</span></font></div>
</div>

<br>
</blockquote></div>
<span></span><br></div></blockquote></div></body></html>