<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        Hi Christoph --<div><br></div><div>> <span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"> </span><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">what would in your eyes be the right way to implement tools like the basic inspector</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Until we can improve proxy representation/implementation in Squeak, I don't think there is a better way to provide some proxy compatibility in BasicInspector. But we might want to treat any use of those mirror-primitives in tools such as BasicInspector as a code smell.</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Best,</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Marcel</span></div><div class="mb_sig"></div><blockquote class='history_container' type='cite' style='border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;'>
                        <p style='color: #AAAAAA; margin-top: 10px;'>Am 14.01.2022 00:43:45 schrieb Thiede, Christoph <christoph.thiede@student.hpi.uni-potsdam.de>:</p><div style='font-family:Arial,Helvetica,sans-serif'>

<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hi Eliot,</p>
<p><br>
</p>
<p>thank you for the reply! :-)</p>
<p><br>
</p>
<p>Just one follow-up question: If you say the mirror primitives should actually not be used outside of simulation, what would in your eyes be the right way to implement tools like the basic inspector, which does not want to follow any proxy redirections, too?
 As I can see it, the only alternative to using mirror primitives in this case would be a special protocol on ProtoObject ("#noMirrorClass", "#noMirrorEqeq:", etc.) which connects to the normal primitives. But this would come with the disadvantage of an unclean
 ProtoObject protocol, so it does not appear desirable to me either. It's a tricky design problem ...</p>
<p><br>
</p>
<p>Best,</p>
<p>Christoph</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif;color: #000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Eliot Miranda <eliot.miranda@gmail.com><br>
<b>Gesendet:</b> Donnerstag, 13. Januar 2022 23:58:37<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] Do we need to provide the mirror primitive on Context (only)?</span>
<div> </div>
</div>
<div>Hi Christoph,
<div dir="ltr"><br>
<blockquote type="cite">On Jan 11, 2022, at 1:52 PM, Thiede, Christoph <Christoph.Thiede@student.hpi.uni-potsdam.de> wrote:<br>
<br>
</blockquote>
</div>
<blockquote type="cite">
<div dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hi Eliot, hi all,</p>
<p>as I have learned from your great explanation about stack frame states and marriage last year, using "thisContext" in your code is more expensive than one might assume naively when thinking of it as a simple variable. This also means that using "thisContext"
 for invoking a mirror primitive is (unnecessarily?) slow:</p>
<p><br>
</p>
<p></p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;font-size: 16px">
</p>
<div><span style="font-size: 12pt">[thisContext object: World eqeq: World] bench. '28,000,000 per second. 35.8 nanoseconds per run. 19.13235 % GC time.' </span></div>
<div><span style="font-size: 12pt"><br>
</span></div>
<p></p>
<div id="Signature" style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;font-size: 16px">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt">
<div name="divtagdefaultwrapper" style="font-family: Calibri, Arial, Helvetica, sans-serif; margin: 0px;">
<div></div>
</div>
</div>
</div>
versus:
<p></p>
<p><br>
</p>
<p></p>
<div><span style="font-size: 12pt">
<div>TestObject >> object: anObject eqeq: anOtherObject </div>
<div><span style="font-size: 12pt;white-space: pre"></span><span style="font-size: 12pt"><primitive: 110></span><br>
</div>
<div><span style="white-space:pre"></span>self primitiveFailed</div>
</span></div>
<div><span style="font-size: 12pt"><br>
</span></div>
<div><span style="font-size: 12pt">
<div style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;font-size: 16px">
obj := TestObject new.</div>
<div style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;font-size: 16px">
[obj object: World eqeq: World] bench '58,900,000 per second. 17 nanoseconds per run. 0 % GC time.' </div>
<div><br>
Twice as fast!</div>
</span></div>
</div>
</div>
</blockquote>
<div><br>
</div>
Quite so.
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<span style="font-size: 12pt">
<div><span style="font-size: 12pt">I am wondering whether it would be useful to copy or move the mirror primitive protocol to another place, maybe on the class-side of Context, given the number of senders to some mirror primitive methods which are different
 from Context. In particular, SimulationStudio makes </span><a href="https://sourcegraph.com/search?q=context:global+thisContext+object+repo:LinqLover/SimulationStudio&patternType=literal" class="OWAAutoLink" title="https://sourcegraph.com/search?q=context:global+thisContext+object+repo:LinqLover/SimulationStudio&amp;patternType=literal
Strg+Klicken oder tippen Sie, um dem Link zu folgen." style="font-size: 12pt">heavy</a><span style="font-size: 12pt">
 use of them, but the BasicInspector, Squot, and some other tools use it, too. :-)</span></div>
</span></div>
</div>
</blockquote>
<div><br>
</div>
I suppose so. I would tolerate the slow down.  This is protocol that completely sidesteps encapsulation so its use should be as encapsulated as possible, and IMO putting the protocol on a class makes it a little too public.  It’s also unnecessary; see below.</div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<span style="font-size: 12pt">
<div><span style="font-size: 12pt">So here are my questions:</span></div>
<div>
<ul style="margin-bottom: 0px; margin-top: 0px;">
<li>Would this be a legitimate use of the mirror primitives or is the (implicit) contract that the receiver must be a context instance or even a context instance on the current stack?</li></ul>
</div>
</span></div>
</div>
</blockquote>
<div><br>
</div>
For me it makes sense that the protocol is on the instance side of Context.  Both conceptually (in the VM) and in execution simulation it is Contexts that obey (execute) bytecode and in doing so sidestep encapsulation.</div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<span style="font-size: 12pt">
<div>
<ul style="margin-bottom: 0px; margin-top: 0px;">
<li>Do you consider the mirror primitive protocol a public protocol or are all senders from different classes actually abusing the protocol?</li></ul>
</div>
</span></div>
</div>
</blockquote>
<div><br>
</div>
No; the mirror protocol is provided to allow Context to implement execution simulation correctly.  As we know, relying on messages to objects results in completely broken results when using proxies.</div>
<div> </div>
<div>
<blockquote type="cite">
<div dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<span style="font-size: 12pt">
<div>
<ul style="margin-bottom: 0px; margin-top: 0px;">
<li>How would you think about moving this protocol to a static place such as Context class?</li></ul>
</div>
</span></div>
</div>
</blockquote>
<div><br>
</div>
<div>I think it’s neither desirable nor necessary.  If Simulation Studio needs to avoid the overhead of Context creation if can surely simply instantiate a Context and use it throughout to invoke the mirror protocol.  Nothing says that one has to use thisContext;
 “Context basicNew objectClass: nil” also works, hence (eg in Simulation Studio)</div>
<div>    initialize</div>
<div>        myMirror := Context receiver: … </div>
<div><br>
</div>
<div>    someMethod: someThing</div>
<div>         | actualClass |</div>
<div>         actualClass := myMirror objectClass: someThing</div>
<div><br>
</div>
<div>will work just fine.</div>
<div><br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<span style="font-size: 12pt">
<div>
<div><br>
</div>
</div>
<div>Thanks in advance!</div>
</span></div>
</div>
</blockquote>
<div><br>
</div>
HTH</div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<span style="font-size: 12pt">
<div><br>
</div>
<div>Best,</div>
<div>Christoph</div>
</span></div>
</div>
</blockquote>
<br>
<div>Eliot</div>
<div>_,,,^..^,,,_ (phone)</div>
</div>
</div>
</div></blockquote>
                                        </div></body>