<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, hi Jaromir,</p>
<p><br>
</p>
<p>I'm raising a new question in this post that is related to the following threads, but I think that it deserves its own thread due to the fundamental criticism expressed: [1, 2]</p>
<div><br>
</div>
<div>I just took a closer look at <b>ProcessTest >> #testNestedUnwind</b> and I have to say that I don't agree with it. I'm sorry that I did not mention this earlier, but somehow this aspect of Jaromir's large amount of recent work has escaped my attention
 before today. For reference, so that we all know what we are talking about, here is the test in question:</div>
<div><br>
</div>
<p></p>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<p></p>
<div>
<div>testNestedUnwind</div>
</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>"Test all nested unwind blocks are correctly unwound; all unwind blocks halfway through their execution should be completed or at least attempted to complete, not only the innermost one"</div>
<p></p>
<p></p>
<div><br>
</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>| p x1 x2 x3 |</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>x1 := x2 := x3 := false.</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>p := </div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>[</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>[</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>[ ] ensure: [ "halfway through completion when suspended"</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>[ ] ensure: [ "halfway through completion when suspended"</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>Processor activeProcess suspend. </div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>x1 := true]. </div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>x2 := true]</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>] ensure: [ "not started yet when suspended"</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>x3 := true]</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>] fork.</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>Processor yield.</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>p terminate.</div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span></div>
<p></p>
<p></p>
<div><span style="white-space:pre"></span>self assert: x1 & x2 & x3.</div>
<p></p>
</blockquote>
<br>
<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>I'm not convinced about the assertions in this test. :-) In fact, I would only expect x3 to be true but x1 and x2 to be false!</div>
<div>IMHO, when terminating a process, halfway-executed unwinded contexts should not be continued. Only not-yet-activated unwind contexts should be triggered.</div>
<div>Here are my arguments:</div>
<div><span style="font-size: 12pt;"><br>
</span></div>
<div>
<ul style="margin-bottom: 0px; margin-top: 0px;">
<li><span style="font-size: 12pt;"><b>Regular unwinding and process termination should have exactly the same behavior.</b></span></li></ul>
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><span style="font-size: 12pt;">Assume we manipulated the example from the test like this:</span></div>
<div><span style="font-size: 12pt;">[</span></div>
<div><b style="white-space: pre; font-size: 12pt;"><span style="color: rgb(255, 0, 0);"></span><span style="color: rgb(255, 0, 0);">[</span></b></div>
<div><span style="font-size: 12pt; white-space: pre;"></span><span style="font-size: 12pt;">[</span></div>
<div><span style="font-size: 12pt; white-space: pre;"></span><span style="font-size: 12pt;">[ ] ensure: [ "halfway through completion when suspended"</span></div>
<div><span style="font-size: 12pt; white-space: pre;"></span><span style="font-size: 12pt;">[ ] ensure: [ "halfway through completion when suspended"</span></div>
<div><b style="font-size: 12pt;"><span style="white-space: pre; color: rgb(255, 0, 0);"></span><span style="color: rgb(255, 0, 0);">self error.</span></b></div>
<div><span style="font-size: 12pt; white-space: pre;"></span><span style="font-size: 12pt;">x1 := true]. </span></div>
<div><span style="font-size: 12pt; white-space: pre;"></span><span style="font-size: 12pt;">x2 := true]</span></div>
<div><span style="font-size: 12pt; white-space: pre;"></span><span style="font-size: 12pt;">] ensure: [ "not started yet when suspended"</span></div>
<div><span style="font-size: 12pt; white-space: pre;"></span><span style="font-size: 12pt;">x3 := true]</span></div>
<div><b style="font-size: 12pt;"><span style="white-space: pre; color: rgb(255, 0, 0);"></span><span style="color: rgb(255, 0, 0);">] on: Error do: []</span></b></div>
<div><span style="font-size: 12pt;">] fork.</span></div>
<div><span style="font-size: 12pt;">I have highlighted the differences, so what I changed was i) to insert an error handler at the bottom of the process and ii) instead of terminating the process, to raise an error in the innermost block.</span></div>
<div><span style="font-size: 12pt;">In this example, only x3 will be set to true which is because the exceptional control flow explicitly discontinues the logic running inside the error handler. Only not-yet-activated unwind contexts will be triggered as part
 of the unwinding, which only applies to the outermost unwind context.</span></div>
<div><span style="font-size: 12pt;">In my view, process termination should have exactly the same semantics as using an exception to abort the control flow.</span></div>
<div><span style="font-size: 12pt;">If we</span><span style="font-size: 12pt;"> woul</span><span style="font-size: 12pt;">d not catch the error in the above example but press Abandon in the appearing debugger instead, I see no reason why we would want to execute
 a different set of unwind contexts.</span></div>
</blockquote>
<div>
<ul style="margin-bottom: 0px; margin-top: 0px;">
<li><span style="font-size: 12pt;">Last but not least, the fact that an error has been signaled means that the signalerContext is "infected" so under no circumstances, abandoning the process should resume the execution of this infected context! (The only exception
 is when you consciously do so via the "Proceed" button in a debugger.) This might become more vivid if I replace the innermost block with the following:</span></li></ul>
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><span style="font-size: 12pt;">x1 := (2 / 0  "error!") > 0.</span></div>
</blockquote>
</blockquote>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><span style="font-size: 12pt;">Actually, it is enough to run the following stand-alone:</span></div>
<div>
<div style="font-size: 12pt;">
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">[] ensure: [</blockquote>
</div>
</div>
<div>
<div style="font-size: 12pt;">
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><span style="white-space:pre"></span>x1 := (2 / 0  "error!") > 0</blockquote>
</div>
</div>
<div>
<div style="font-size: 12pt;">
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">]</blockquote>
</div>
</div>
<div><span style="font-size: 12pt;">If you debug the </span><span style="font-size: 12pt;">Abandon button</span><span style="font-size: 12pt;">, you can see that another error </span><span style="font-size: 12pt;">occurs
</span><span style="font-size: 12pt;">while terminating the </span><span style="font-size: 12pt;">process, which is a
<b>MessageNotUnderstood for #> in ZeroDivision.</b> The only </span><span style="font-size: 12pt;">reason</span><span style="font-size: 12pt;">
</span><span style="font-size: 12pt;">why</span><span style="font-size: 12pt;"> a second debugger does not appear is the current bug in Process >> #terminate which "absorbs" subsequent error in this situation and which is currently being discussed in [2].</span></div>
</blockquote>
<div>
<div><br>
</div>
</div>
<div>Sorry for the long message! I hope that you agree with my arguments, and if not, I am very excited to hear your ones. :-) Unless contradicted, I would like to request to change #<span>testNestedUnwind as described above and use the changed version as the
 general basis for the ongoing discussions in [1, 2]. But maybe I am also just committing a fatal case of false reasoning ... :-)</span></div>
<div><span><br>
</span></div>
<div><span>Best,</span></div>
<div><span>Christoph</span></div>
<div><br>
</div>
<div>
<div>[1] http://forum.world.st/The-Inbox-Kernel-ct-1405-mcz-td5129706.html</div>
<div>[2] http://forum.world.st/stepping-over-non-local-return-in-a-protected-block-td5128777.html</div>
</div>
</div>
</body>
</html>