<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:large">Hi Christoph,<br></div><div class="gmail_default" style="font-size:large"><br></div><div class="gmail_default" style="font-size:large">    can you please submit a merge of your changes here with Kernel-eem.1359 and then we can move your contribution to trunk.  Always submitting deltas to other inbox versions means one of us has to merge and that could be perceived as a little passive aggressive ;-).</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Nov 1, 2020 at 10:51 AM <<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">A new version of Kernel was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Kernel-ct.1359.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/Kernel-ct.1359.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Kernel-ct.1359<br>
Author: ct<br>
Time: 1 November 2020, 7:50:24.183428 pm<br>
UUID: 3b12b316-79f3-de41-8765-8296d964b821<br>
Ancestors: Kernel-mt.1353<br>
<br>
Revise and extend Context #runSimulated: implementation. Remove restriction to blocks that do not have a method return. Add support for exception signaling during the execution, which caused unterminated simulation of the calling process in the past. Support argless contextAtEachStep blocks.<br>
<br>
Benchmarks:<br>
        code:<br>
                [Context runSimulated: [100@100 corner: 200@200]] bench<br>
        before:<br>
                16.7 ms/run<br>
        after:<br>
                19.8 ms/run<br>
I think this should be okay, given the fact that the primary purpose of simulation is providing explorability but not efficiency ...<br>
<br>
=============== Diff against Kernel-mt.1353 ===============<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>runSimulated: (in category 'simulation') -----<br>
  runSimulated: aBlock<br>
+       "Simulate the execution of aBlock, until it ends or is curtailed. Answer the result it returns."<br>
-       "Simulate the execution of the argument, current. Answer the result it <br>
-       returns."<br>
<br>
        ^ thisContext sender<br>
                runSimulated: aBlock<br>
+               contextAtEachStep: []<br>
-               contextAtEachStep: [:ignored]<br>
<br>
        "Context runSimulated: [Pen new defaultNib: 5; go: 100]"!<br>
<br>
Item was changed:<br>
  ----- Method: Context>>runSimulated:contextAtEachStep: (in category 'system simulation') -----<br>
+ runSimulated: aBlock contextAtEachStep: anotherBlock<br>
+       "Simulate the execution of the argument, aBlock, until it ends or is curtailed. If any exception is signaled during the execution, simulate it being handled on the present caller stack. Evaluate anotherBlock with the current context prior to each instruction executed. Answer the simulated value of aBlock."<br>
+ <br>
+       | current resume ensure |<br>
+       resume := false.<br>
- runSimulated: aBlock contextAtEachStep: block2<br>
-       "Simulate the execution of the argument, aBlock, until it ends. aBlock <br>
-       MUST NOT contain an '^'. Evaluate block2 with the current context <br>
-       prior to each instruction executed. Answer the simulated value of aBlock."<br>
-       | current |<br>
-       aBlock hasMethodReturn<br>
-               ifTrue: [self error: 'simulation of blocks with ^ can run loose'].<br>
        current := aBlock asContext.<br>
+       ensure := current insertSender: (Context contextEnsure: [resume := true]).<br>
+       ensure sender ifNil: [ensure privSender: self]. "For backward compatibility, do not fail if aBlock is dead."<br>
+       <br>
+       (anotherBlock numArgs = 0<br>
+               ifTrue: ["optimized" [resume]]<br>
+               ifFalse: ["stop execution on time, don't expose simulation details to caller"<br>
+                       [current == ensure or: <br>
+                               ["Context >> #resume:"<br>
+                               current size >= 2 and: <br>
+                                       [(current at: 2) == ensure]]]   ])<br>
-       current pushArgs: Array new from: self.<br>
-       [current == self]<br>
                whileFalse:<br>
+                       [anotherBlock cull: current.<br>
-                       [block2 value: current.<br>
                        current := current step].<br>
+       <br>
+       ^ current jump!<br>
-       ^self pop!<br>
<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>